pub(crate) struct StringReader<'input> {
input: &'input str,
total_length: usize,
cursor: ReaderCursor,
}Expand description
Reads command input while exposing Brigadier-compatible UTF-16 positions.
Fields§
§input: &'input str§total_length: usize§cursor: ReaderCursorImplementations§
Source§impl<'input> StringReader<'input>
impl<'input> StringReader<'input>
Sourcepub(crate) const fn total_length(&self) -> usize
pub(crate) const fn total_length(&self) -> usize
Returns the input length in UTF-16 code units.
Sourcepub(crate) const fn byte_cursor(&self) -> usize
pub(crate) const fn byte_cursor(&self) -> usize
Returns the current position in UTF-8 bytes.
Sourcepub(crate) const fn remaining_length(&self) -> usize
pub(crate) const fn remaining_length(&self) -> usize
Returns the remaining length in UTF-16 code units.
Sourcepub(crate) fn can_read_length(&self, length: usize) -> bool
pub(crate) fn can_read_length(&self, length: usize) -> bool
Returns whether length UTF-16 code units remain.
Sourcepub(crate) fn peek(&self) -> Option<char>
pub(crate) fn peek(&self) -> Option<char>
Returns the next Unicode scalar without advancing the reader.
Sourcepub(crate) fn read_so_far(&self) -> &'input str
pub(crate) fn read_so_far(&self) -> &'input str
Returns the input before the cursor.
Sourcepub(crate) fn read_remaining(&mut self) -> &'input str
pub(crate) fn read_remaining(&mut self) -> &'input str
Reads all remaining input.
Sourcepub(crate) fn advance_bytes(&mut self, bytes: usize) -> bool
pub(crate) fn advance_bytes(&mut self, bytes: usize) -> bool
Advances by an exact UTF-8 byte count while retaining Brigadier’s UTF-16 cursor.
Sourcepub(crate) fn skip_whitespace(&mut self)
pub(crate) fn skip_whitespace(&mut self)
Advances past whitespace recognized by Java’s Character.isWhitespace.
Sourcepub(crate) fn read_unquoted_string(&mut self) -> &'input str
pub(crate) fn read_unquoted_string(&mut self) -> &'input str
Reads an unquoted Brigadier string.
Sourcepub(crate) fn read_unquoted_token(&mut self) -> &'input str
pub(crate) fn read_unquoted_token(&mut self) -> &'input str
Reads one custom argument token up to Java-compatible whitespace.
Sourcepub(crate) fn read_quoted_string(
&mut self,
) -> Result<String, CommandSyntaxError>
pub(crate) fn read_quoted_string( &mut self, ) -> Result<String, CommandSyntaxError>
Reads a single- or double-quoted Brigadier string.
Sourcepub(crate) fn read_string(&mut self) -> Result<String, CommandSyntaxError>
pub(crate) fn read_string(&mut self) -> Result<String, CommandSyntaxError>
Reads a quoted or unquoted Brigadier string.
Sourcepub(crate) fn read_int(&mut self) -> Result<i32, CommandSyntaxError>
pub(crate) fn read_int(&mut self) -> Result<i32, CommandSyntaxError>
Reads a signed 32-bit integer.
Sourcepub(crate) fn read_long(&mut self) -> Result<i64, CommandSyntaxError>
pub(crate) fn read_long(&mut self) -> Result<i64, CommandSyntaxError>
Reads a signed 64-bit integer.
Sourcepub(crate) fn read_double(&mut self) -> Result<f64, CommandSyntaxError>
pub(crate) fn read_double(&mut self) -> Result<f64, CommandSyntaxError>
Reads a 64-bit floating-point number.
Sourcepub(crate) fn read_float(&mut self) -> Result<f32, CommandSyntaxError>
pub(crate) fn read_float(&mut self) -> Result<f32, CommandSyntaxError>
Reads a 32-bit floating-point number.
Sourcepub(crate) fn read_boolean(&mut self) -> Result<bool, CommandSyntaxError>
pub(crate) fn read_boolean(&mut self) -> Result<bool, CommandSyntaxError>
Reads a lowercase Brigadier boolean.
Sourcepub(crate) fn expect(
&mut self,
expected: char,
) -> Result<(), CommandSyntaxError>
pub(crate) fn expect( &mut self, expected: char, ) -> Result<(), CommandSyntaxError>
Consumes expected or returns a contextual syntax error.
pub(super) fn try_read_literal(&mut self, literal: &str) -> bool
fn read_string_until( &mut self, terminator: char, ) -> Result<String, CommandSyntaxError>
fn read_number<T>(
&mut self,
expected: CommandSyntaxErrorKind,
invalid: fn(Box<str>) -> CommandSyntaxErrorKind,
) -> Result<T, CommandSyntaxError>where
T: FromStr,
Sourcepub(crate) const fn checkpoint(&self) -> ReaderCursor
pub(crate) const fn checkpoint(&self) -> ReaderCursor
Captures the current reader position for later restoration.
Sourcepub(crate) const fn restore(&mut self, checkpoint: ReaderCursor)
pub(crate) const fn restore(&mut self, checkpoint: ReaderCursor)
Restores a position previously returned by Self::checkpoint.
Sourcepub(crate) fn error(&self, kind: CommandSyntaxErrorKind) -> CommandSyntaxError
pub(crate) fn error(&self, kind: CommandSyntaxErrorKind) -> CommandSyntaxError
Creates a syntax error at the current reader position.
const fn is_allowed_number(character: char) -> bool
const fn is_quoted_string_start(character: char) -> bool
const fn is_allowed_in_unquoted_string(character: char) -> bool
Trait Implementations§
Source§impl<'input> Clone for StringReader<'input>
impl<'input> Clone for StringReader<'input>
Source§fn clone(&self) -> StringReader<'input>
fn clone(&self) -> StringReader<'input>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<'input> Freeze for StringReader<'input>
impl<'input> RefUnwindSafe for StringReader<'input>
impl<'input> Send for StringReader<'input>
impl<'input> Sync for StringReader<'input>
impl<'input> Unpin for StringReader<'input>
impl<'input> UnsafeUnpin for StringReader<'input>
impl<'input> UnwindSafe for StringReader<'input>
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 moreArc<SyncMutex<>>