pub struct Node { /* private fields */ }Expand description
A WAVE AST node.
Implementations§
source§impl Node
impl Node
sourcepub fn as_bool(&self) -> Result<bool, ParserError>
pub fn as_bool(&self) -> Result<bool, ParserError>
Returns a bool value if this node represents a bool.
sourcepub fn as_number<T: FromStr>(&self, src: &str) -> Result<T, ParserError>
pub fn as_number<T: FromStr>(&self, src: &str) -> Result<T, ParserError>
Returns a number value of the given type (integer or float) if this node can represent a number of that type.
sourcepub fn as_char(&self, src: &str) -> Result<char, ParserError>
pub fn as_char(&self, src: &str) -> Result<char, ParserError>
Returns a char value if this node represents a valid char.
sourcepub fn as_str<'src>(
&self,
src: &'src str,
) -> Result<Cow<'src, str>, ParserError>
pub fn as_str<'src>( &self, src: &'src str, ) -> Result<Cow<'src, str>, ParserError>
Returns a str value if this node represents a valid string.
sourcepub fn iter_str<'src>(
&self,
src: &'src str,
) -> Result<impl Iterator<Item = Result<Cow<'src, str>, ParserError>>, ParserError>
pub fn iter_str<'src>( &self, src: &'src str, ) -> Result<impl Iterator<Item = Result<Cow<'src, str>, ParserError>>, ParserError>
Returns an iterator of string “parts” which together form a decoded string value if this node represents a valid string.
sourcepub fn as_tuple(
&self,
) -> Result<impl ExactSizeIterator<Item = &Node>, ParserError>
pub fn as_tuple( &self, ) -> Result<impl ExactSizeIterator<Item = &Node>, ParserError>
Returns an iterator of value nodes if this node represents a tuple.
sourcepub fn as_list(
&self,
) -> Result<impl ExactSizeIterator<Item = &Node>, ParserError>
pub fn as_list( &self, ) -> Result<impl ExactSizeIterator<Item = &Node>, ParserError>
Returns an iterator of value nodes if this node represents a list.
sourcepub fn as_record<'this, 'src>(
&'this self,
src: &'src str,
) -> Result<impl ExactSizeIterator<Item = (&'src str, &'this Node)>, ParserError>
pub fn as_record<'this, 'src>( &'this self, src: &'src str, ) -> Result<impl ExactSizeIterator<Item = (&'src str, &'this Node)>, ParserError>
Returns an iterator of field name and value node pairs if this node represents a record value.
sourcepub fn as_variant<'this, 'src>(
&'this self,
src: &'src str,
) -> Result<(&'src str, Option<&'this Node>), ParserError>
pub fn as_variant<'this, 'src>( &'this self, src: &'src str, ) -> Result<(&'src str, Option<&'this Node>), ParserError>
Returns a variant label and optional payload if this node can represent a variant value.
sourcepub fn as_enum<'src>(&self, src: &'src str) -> Result<&'src str, ParserError>
pub fn as_enum<'src>(&self, src: &'src str) -> Result<&'src str, ParserError>
Returns an enum value label if this node represents a label.
sourcepub fn as_option(&self) -> Result<Option<&Node>, ParserError>
pub fn as_option(&self) -> Result<Option<&Node>, ParserError>
Returns an option value if this node represents an option.
sourcepub fn as_result(
&self,
) -> Result<Result<Option<&Node>, Option<&Node>>, ParserError>
pub fn as_result( &self, ) -> Result<Result<Option<&Node>, Option<&Node>>, ParserError>
Returns a result value with optional payload value if this node represents a result.
sourcepub fn as_flags<'this, 'src: 'this>(
&'this self,
src: &'src str,
) -> Result<impl Iterator<Item = &'src str> + 'this, ParserError>
pub fn as_flags<'this, 'src: 'this>( &'this self, src: &'src str, ) -> Result<impl Iterator<Item = &'src str> + 'this, ParserError>
Returns an iterator of flag labels if this node represents flags.
sourcepub fn to_wasm_value<V: WasmValue>(
&self,
ty: &V::Type,
src: &str,
) -> Result<V, ParserError>
pub fn to_wasm_value<V: WasmValue>( &self, ty: &V::Type, src: &str, ) -> Result<V, ParserError>
Converts this node into the given typed value from the given input source.
sourcepub fn to_wasm_params<'types, V: WasmValue + 'static>(
&self,
types: impl IntoIterator<Item = &'types V::Type>,
src: &str,
) -> Result<Vec<V>, ParserError>
pub fn to_wasm_params<'types, V: WasmValue + 'static>( &self, types: impl IntoIterator<Item = &'types V::Type>, src: &str, ) -> Result<Vec<V>, ParserError>
Converts this node into the given types.
See crate::untyped::UntypedFuncCall::to_wasm_params.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnwindSafe for Node
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)