Module

Struct Module 

Source
pub struct Module { /* private fields */ }
Expand description

A compiled bytecode module.

Instructions are decoded lazily via decode_step. Cold data (strings, symbols, types) is accessed through view methods.

Implementations§

Source§

impl Module

Source

pub fn from_aligned(vec: AlignedVec) -> Result<Self, ModuleError>

Load a module from an aligned vector (compiler output).

This is the primary constructor for bytecode produced by the compiler.

Source

pub fn from_static(bytes: &'static [u8]) -> Result<Self, ModuleError>

Load a module from static bytes (zero-copy).

Use with include_query_aligned! to embed aligned bytecode:

use plotnik_lib::include_query_aligned;

let module = Module::from_static(include_query_aligned!("query.ptk.bin"))?;
§Panics

Panics if bytes are not 64-byte aligned.

Source

pub fn from_path(path: impl AsRef<Path>) -> Result<Self, ModuleError>

Load a module from a file path.

Reads the file into 64-byte aligned storage.

Source

pub fn load(bytes: &[u8]) -> Result<Self, ModuleError>

Load a module from arbitrary bytes (copies into aligned storage).

Use this for bytes from unknown sources (network, etc.). Always copies.

Source

pub fn from_bytes(bytes: Vec<u8>) -> Result<Self, ModuleError>

👎Deprecated since 0.1.0: use Module::from_aligned for AlignedVec or Module::load for copying

Load a module from owned bytes (copies into aligned storage).

Source

pub fn header(&self) -> &Header

Get the parsed header.

Source

pub fn offsets(&self) -> &SectionOffsets

Get the computed section offsets.

Source

pub fn bytes(&self) -> &[u8]

Get the raw bytes.

Source

pub fn decode_step(&self, step: u16) -> Instruction<'_>

Decode an instruction at the given step index.

Source

pub fn strings(&self) -> StringsView<'_>

Get a view into the string table.

Source

pub fn node_types(&self) -> SymbolsView<'_, NodeSymbol>

Get a view into the node type symbols.

Source

pub fn node_fields(&self) -> SymbolsView<'_, FieldSymbol>

Get a view into the node field symbols.

Source

pub fn trivia(&self) -> TriviaView<'_>

Get a view into the trivia entries.

Source

pub fn regexes(&self) -> RegexView<'_>

Get a view into the regex table.

Source

pub fn types(&self) -> TypesView<'_>

Get a view into the type metadata.

Source

pub fn entrypoints(&self) -> EntrypointsView<'_>

Get a view into the entrypoints.

Trait Implementations§

Source§

impl Debug for Module

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Module

§

impl RefUnwindSafe for Module

§

impl Send for Module

§

impl Sync for Module

§

impl Unpin for Module

§

impl UnwindSafe for Module

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.