Struct Node
pub struct Node { /* private fields */ }
Expand description
A WAVE AST node.
Implementations§
§impl Node
impl Node
pub 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.
pub fn as_number<T>(&self, src: &str) -> Result<T, ParserError>where
T: FromStr,
pub fn as_number<T>(&self, src: &str) -> Result<T, ParserError>where
T: FromStr,
Returns a number value of the given type (integer or float) if this node can represent a number of that type.
pub 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.
pub 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.
pub 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.
pub fn as_tuple(&self) -> Result<impl ExactSizeIterator, ParserError>
pub fn as_tuple(&self) -> Result<impl ExactSizeIterator, ParserError>
Returns an iterator of value nodes if this node represents a tuple.
pub fn as_list(&self) -> Result<impl ExactSizeIterator, ParserError>
pub fn as_list(&self) -> Result<impl ExactSizeIterator, ParserError>
Returns an iterator of value nodes if this node represents a list.
pub fn as_record<'this, 'src>(
&'this self,
src: &'src str,
) -> Result<impl ExactSizeIterator, ParserError>
pub fn as_record<'this, 'src>( &'this self, src: &'src str, ) -> Result<impl ExactSizeIterator, ParserError>
Returns an iterator of field name and value node pairs if this node represents a record value.
pub 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.
pub 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.
pub 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.
pub 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.
pub fn as_flags<'this, 'src>(
&'this self,
src: &'src str,
) -> Result<impl Iterator<Item = &'src str> + 'this, ParserError>where
'src: 'this,
pub fn as_flags<'this, 'src>(
&'this self,
src: &'src str,
) -> Result<impl Iterator<Item = &'src str> + 'this, ParserError>where
'src: 'this,
Returns an iterator of flag labels if this node represents flags.
pub fn to_wasm_value<V>(
&self,
ty: &<V as WasmValue>::Type,
src: &str,
) -> Result<V, ParserError>where
V: WasmValue,
pub fn to_wasm_value<V>(
&self,
ty: &<V as WasmValue>::Type,
src: &str,
) -> Result<V, ParserError>where
V: WasmValue,
Converts this node into the given typed value from the given input source.
pub fn to_wasm_params<'types, V>(
&self,
types: impl IntoIterator<Item = &'types <V as WasmValue>::Type>,
src: &str,
) -> Result<Vec<V>, ParserError>where
V: WasmValue + 'static,
pub fn to_wasm_params<'types, V>(
&self,
types: impl IntoIterator<Item = &'types <V as WasmValue>::Type>,
src: &str,
) -> Result<Vec<V>, ParserError>where
V: WasmValue + 'static,
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more