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
.