pub trait TokenSource<'input> {
// Required methods
fn next_token(&mut self) -> Result<SpannedAdapterToken<'input>, JsonError>;
fn skip(&mut self) -> Result<Span, JsonError>;
// Provided methods
fn input_bytes(&self) -> Option<&'input [u8]> { ... }
fn at_offset(&self, offset: usize) -> Option<Self>
where Self: Sized { ... }
}Expand description
Trait for token sources that can be used by the deserializer.
This trait abstracts over both:
SliceAdapter<'input>implementsTokenSource<'input>- can borrow from inputStreamingAdapterimplementsTokenSource<'static>- always owned
The lifetime parameter 'input is the lifetime of the input data,
NOT the lifetime of self. This is why we don’t need GATs.
Required Methods§
Sourcefn next_token(&mut self) -> Result<SpannedAdapterToken<'input>, JsonError>
fn next_token(&mut self) -> Result<SpannedAdapterToken<'input>, JsonError>
Get the next token.
Provided Methods§
Sourcefn input_bytes(&self) -> Option<&'input [u8]>
fn input_bytes(&self) -> Option<&'input [u8]>
Get the raw input bytes, if available.
Returns Some for slice-based adapters, None for streaming.
Used for features that need direct input access (RawJson, flatten replay).