pub struct CodeModuleValue { /* private fields */ }Expand description
Owned CCMAS value + AST builder. Constructs canonical CCMAS bytes
programmatically for reference and testing. alloc-gated — the
pipeline binds the borrowed CodeModuleCarrier handle, which needs
no allocator. There is no width / count ceiling.
Implementations§
Source§impl CodeModuleValue
impl CodeModuleValue
Sourcepub fn parse(raw: &[u8]) -> Result<Self, ShapeViolation>
pub fn parse(raw: &[u8]) -> Result<Self, ShapeViolation>
Parse + canonicalize raw CCMAS bytes (Rivest canonical or token-list form), retaining the canonical bytes.
§Errors
A validCcmas/validUtf8SExpr ShapeViolation if raw is not
a well-formed S-expression.
Sourcepub fn module(name: &str, items: &[CodeModuleValue]) -> Self
pub fn module(name: &str, items: &[CodeModuleValue]) -> Self
Build a Module AST node: (3:mod <name> <item>…).
Sourcepub fn function(
name: &str,
parameters: &[CodeModuleValue],
return_type: &CodeModuleValue,
body: &CodeModuleValue,
) -> Self
pub fn function( name: &str, parameters: &[CodeModuleValue], return_type: &CodeModuleValue, body: &CodeModuleValue, ) -> Self
Build a Function AST node: (3:fun <name> (<param>…) <ret> <body>).
Sourcepub fn atom(text: &str) -> Self
pub fn atom(text: &str) -> Self
Build an Atom AST node (Identifier, Literal, etc.): <len>:<text>.
Sourcepub fn tagged_bytes(&self) -> &[u8] ⓘ
pub fn tagged_bytes(&self) -> &[u8] ⓘ
Borrow the CCMAS canonical bytes.
Trait Implementations§
Source§impl Clone for CodeModuleValue
impl Clone for CodeModuleValue
Source§fn clone(&self) -> CodeModuleValue
fn clone(&self) -> CodeModuleValue
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 CodeModuleValue
Available on crate feature alloc only.
impl Debug for CodeModuleValue
Available on crate feature
alloc only.Source§impl PartialEq for CodeModuleValue
impl PartialEq for CodeModuleValue
Source§fn eq(&self, other: &CodeModuleValue) -> bool
fn eq(&self, other: &CodeModuleValue) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for CodeModuleValue
impl StructuralPartialEq for CodeModuleValue
Auto Trait Implementations§
impl Freeze for CodeModuleValue
impl RefUnwindSafe for CodeModuleValue
impl Send for CodeModuleValue
impl Sync for CodeModuleValue
impl Unpin for CodeModuleValue
impl UnsafeUnpin for CodeModuleValue
impl UnwindSafe for CodeModuleValue
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