-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36c4338
commit fb577de
Showing
4 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use crate::Base; | ||
use core::slice::from_raw_parts; | ||
|
||
#[derive(Debug)] | ||
pub struct Header { | ||
base: Base, | ||
len: usize, | ||
} | ||
|
||
impl Header { | ||
/// Returns a base pointer of this section. | ||
#[inline] | ||
pub fn base(&self) -> Base { | ||
self.base | ||
} | ||
|
||
/// Returns the length of this section. | ||
#[inline] | ||
#[allow(clippy::len_without_is_empty)] | ||
pub fn len(&self) -> usize { | ||
self.len | ||
} | ||
|
||
#[inline] | ||
pub fn as_slice(&self) -> &[u8] { | ||
unsafe { from_raw_parts(self.base.as_nonnull().as_ptr(), self.len) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
//! # Inka | ||
mod base; | ||
mod header; | ||
mod program; | ||
mod section; | ||
|
||
pub use base::Base; | ||
pub use header::Header; | ||
pub use program::{program, Program}; | ||
pub use section::Section; | ||
|
||
pub type Name = &'static str; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters