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

source

pub const LIBRARY_EXTENSION: &'static str = "masl"

File extension for the Assembly Library.

source

pub const MODULE_EXTENSION: &'static str = "masm"

File extension for the Assembly Module.

source

pub const MOD: &'static str = "mod"

Name of the root module.

source

pub fn new( namespace: LibraryNamespace, version: Version, has_source_locations: bool, modules: Vec<Module>, dependencies: Vec<LibraryNamespace> ) -> Result<MaslLibrary, LibraryError>

Returns a new Library instantiated from the specified parameters.

§Errors

Returns an error if the provided modules vector is empty or contains more than u16::MAX elements.

source

pub fn clear_locations(&mut self)

Clears the source locations from this bundle.

source§

impl MaslLibrary

source

pub fn read_from_dir<P>( path: P, namespace: LibraryNamespace, with_source_locations: bool, version: Version ) -> Result<MaslLibrary, Error>
where P: AsRef<Path>,

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))
source

pub fn read_from_file<P>(path: P) -> Result<MaslLibrary, LibraryError>
where P: AsRef<Path>,

Read a library from a file.

source

pub fn write_to_dir<P>(&self, dir_path: P) -> Result<(), Error>
where P: AsRef<Path>,

Write the library to a target director, using its namespace as file name and the appropriate extension.

Trait Implementations§

source§

impl Clone for MaslLibrary

source§

fn clone(&self) -> MaslLibrary

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MaslLibrary

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Deserializable for MaslLibrary

source§

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 more
source§

fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>

Attempts to deserialize the provided bytes into Self and returns the result. Read more
source§

impl Library for MaslLibrary

§

type ModuleIterator<'a> = Iter<'a, Module>

The concrete type used to iterate the modules of the library.
source§

fn root_ns(&self) -> &LibraryNamespace

Returns the root namespace of this library.
source§

fn version(&self) -> &Version

Returns the version number of this library.
source§

fn modules(&self) -> <MaslLibrary as Library>::ModuleIterator<'_>

Iterate the modules available in the library.
source§

fn dependencies(&self) -> &[LibraryNamespace]

Returns the dependency libraries of this library.
source§

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

source§

fn eq(&self, other: &MaslLibrary) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serializable for MaslLibrary

source§

fn write_into<W>(&self, target: &mut W)
where W: ByteWriter,

Serializes self into bytes and writes these bytes into the target.
source§

fn to_bytes(&self) -> Vec<u8>

Serializes self into a vector of bytes.
source§

fn get_size_hint(&self) -> usize

Returns an estimate of how many bytes are needed to represent self. Read more
source§

impl Eq for MaslLibrary

source§

impl StructuralPartialEq for MaslLibrary

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more