pub trait ASTNode: Sized + Clone + PartialEq + Debug + Sync + Send + 'static {
// Required methods
fn get_position(&self) -> &BaseSpan<()>;
fn from_reader(
reader: &mut impl TokenReader<TSXToken, Start>,
state: &mut ParsingState,
options: &ParseOptions
) -> Result<Self, ParseError>;
fn to_string_from_buffer<T>(
&self,
buf: &mut T,
options: &ToStringOptions,
depth: u8
)
where T: ToString;
// Provided methods
fn from_string(
script: String,
options: ParseOptions,
source: SourceId,
offset: Option<u32>
) -> Result<Self, ParseError> { ... }
fn to_string(&self, options: &ToStringOptions) -> String { ... }
}Expand description
Defines common methods that would exist on a AST part include position in source, creation from reader and serializing to string from options.
TODO remove partial eq
Required Methods§
sourcefn get_position(&self) -> &BaseSpan<()>
fn get_position(&self) -> &BaseSpan<()>
Returns position of node as span AS IT WAS PARSED. May be Span::NULL if AST was doesn’t match anything in source
fn from_reader( reader: &mut impl TokenReader<TSXToken, Start>, state: &mut ParsingState, options: &ParseOptions ) -> Result<Self, ParseError>
fn to_string_from_buffer<T>( &self, buf: &mut T, options: &ToStringOptions, depth: u8 )where T: ToString,
Provided Methods§
sourcefn from_string(
script: String,
options: ParseOptions,
source: SourceId,
offset: Option<u32>
) -> Result<Self, ParseError>
fn from_string( script: String, options: ParseOptions, source: SourceId, offset: Option<u32> ) -> Result<Self, ParseError>
From string, with default impl to call abstract method from_reader
sourcefn to_string(&self, options: &ToStringOptions) -> String
fn to_string(&self, options: &ToStringOptions) -> String
Returns structure as valid string
Object Safety§
This trait is not object safe.