pub struct Token {
pub token_type: TokenType,
pub start_position: Position,
pub end_position: Position,
}Expand description
Represents a YAML token with position information
Fields§
§token_type: TokenTypeThe type of token
start_position: PositionStart position of the token
end_position: PositionEnd position of the token
Implementations§
Source§impl Token
impl Token
Sourcepub const fn new(
token_type: TokenType,
start_position: Position,
end_position: Position,
) -> Self
pub const fn new( token_type: TokenType, start_position: Position, end_position: Position, ) -> Self
Create a new token
Sourcepub const fn simple(token_type: TokenType, position: Position) -> Self
pub const fn simple(token_type: TokenType, position: Position) -> Self
Create a simple token at a single position
Sourcepub const fn token_type(&self) -> &TokenType
pub const fn token_type(&self) -> &TokenType
Get the token type
Sourcepub const fn start_position(&self) -> Position
pub const fn start_position(&self) -> Position
Get the start position
Sourcepub const fn end_position(&self) -> Position
pub const fn end_position(&self) -> Position
Get the end position
Sourcepub fn as_scalar_with_style(&self) -> Option<(&str, QuoteStyle)>
pub fn as_scalar_with_style(&self) -> Option<(&str, QuoteStyle)>
Get scalar value and quote style if this is a scalar token
Sourcepub const fn is_flow_collection_start(&self) -> bool
pub const fn is_flow_collection_start(&self) -> bool
Check if this is a flow collection start token
Sourcepub const fn is_flow_collection_end(&self) -> bool
pub const fn is_flow_collection_end(&self) -> bool
Check if this is a flow collection end token
Sourcepub const fn is_block_collection_start(&self) -> bool
pub const fn is_block_collection_start(&self) -> bool
Check if this is a block collection start token
Sourcepub const fn is_document_boundary(&self) -> bool
pub const fn is_document_boundary(&self) -> bool
Check if this is a document boundary token
Trait Implementations§
impl Eq for Token
impl StructuralPartialEq for Token
Auto Trait Implementations§
impl Freeze for Token
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnwindSafe for Token
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.