Struct miden_objects::assembly::MaslLibrary
source · pub struct MaslLibrary { /* private fields */ }Expand description
A concrete implementation of the Library trait. Contains the minimal attributes of a functional library.
Implementers of the library trait should use this base type to perform serialization into
masl files.
Implementations§
source§impl MaslLibrary
impl MaslLibrary
sourcepub const LIBRARY_EXTENSION: &'static str = "masl"
pub const LIBRARY_EXTENSION: &'static str = "masl"
File extension for the Assembly Library.
sourcepub const MODULE_EXTENSION: &'static str = "masm"
pub const MODULE_EXTENSION: &'static str = "masm"
File extension for the Assembly Module.
sourcepub fn new(
namespace: LibraryNamespace,
version: Version,
has_source_locations: bool,
modules: Vec<Module>,
dependencies: Vec<LibraryNamespace>
) -> Result<MaslLibrary, LibraryError>
pub fn new( namespace: LibraryNamespace, version: Version, has_source_locations: bool, modules: Vec<Module>, dependencies: Vec<LibraryNamespace> ) -> Result<MaslLibrary, LibraryError>
sourcepub fn clear_locations(&mut self)
pub fn clear_locations(&mut self)
Clears the source locations from this bundle.
source§impl MaslLibrary
impl MaslLibrary
sourcepub fn read_from_dir<P>(
path: P,
namespace: LibraryNamespace,
with_source_locations: bool,
version: Version
) -> Result<MaslLibrary, Error>
pub fn read_from_dir<P>( path: P, namespace: LibraryNamespace, with_source_locations: bool, version: Version ) -> Result<MaslLibrary, Error>
Read a directory and recursively create modules from its masm files.
For every directory, concatenate the module path with the dir name and proceed.
For every file, pick and parse the ones with masm extension; skip otherwise.
Example:
- ./sys.masm -> (“sys”, ast(./sys.masm))
- ./crypto/hash.masm -> (“crypto::hash”, ast(./crypto/hash.masm))
- ./math/u32.masm -> (“math::u32”, ast(./math/u32.masm))
- ./math/u64.masm -> (“math::u64”, ast(./math/u64.masm))
sourcepub fn read_from_file<P>(path: P) -> Result<MaslLibrary, LibraryError>
pub fn read_from_file<P>(path: P) -> Result<MaslLibrary, LibraryError>
Read a library from a file.
Trait Implementations§
source§impl Clone for MaslLibrary
impl Clone for MaslLibrary
source§fn clone(&self) -> MaslLibrary
fn clone(&self) -> MaslLibrary
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for MaslLibrary
impl Debug for MaslLibrary
source§impl Deserializable for MaslLibrary
impl Deserializable for MaslLibrary
source§fn read_from<R>(source: &mut R) -> Result<MaslLibrary, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<MaslLibrary, DeserializationError>where
R: ByteReader,
Reads a sequence of bytes from the provided
source, attempts to deserialize these bytes
into Self, and returns the result. Read moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl Library for MaslLibrary
impl Library for MaslLibrary
§type ModuleIterator<'a> = Iter<'a, Module>
type ModuleIterator<'a> = Iter<'a, Module>
The concrete type used to iterate the modules of the library.
source§fn root_ns(&self) -> &LibraryNamespace
fn root_ns(&self) -> &LibraryNamespace
Returns the root namespace of this library.
source§fn modules(&self) -> <MaslLibrary as Library>::ModuleIterator<'_>
fn modules(&self) -> <MaslLibrary as Library>::ModuleIterator<'_>
Iterate the modules available in the library.
source§fn dependencies(&self) -> &[LibraryNamespace]
fn dependencies(&self) -> &[LibraryNamespace]
Returns the dependency libraries of this library.
source§fn get_module_ast(&self, path: &LibraryPath) -> Option<&ModuleAst>
fn get_module_ast(&self, path: &LibraryPath) -> Option<&ModuleAst>
Returns the AST of the module stored at the provided path.
source§impl PartialEq for MaslLibrary
impl PartialEq for MaslLibrary
source§fn eq(&self, other: &MaslLibrary) -> bool
fn eq(&self, other: &MaslLibrary) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl Serializable for MaslLibrary
impl Serializable for MaslLibrary
source§fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
Serializes
self into bytes and writes these bytes into the target.source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
Returns an estimate of how many bytes are needed to represent self. Read more
impl Eq for MaslLibrary
impl StructuralPartialEq for MaslLibrary
Auto Trait Implementations§
impl RefUnwindSafe for MaslLibrary
impl Send for MaslLibrary
impl Sync for MaslLibrary
impl Unpin for MaslLibrary
impl UnwindSafe for MaslLibrary
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more