FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    SpanStringTokenizer

    struct · ferroui-base · v0.5.0

    struct SpanStringTokenizer<'a>
    

    Splits a string into tokens separated by white space and/or a single separator character, reading them as integers, doubles or raw slices.

    Reading can fail in two distinct ways, mirrored by the try_read_* signatures: Ok(None) means "no (valid) value here", Err means the input is malformed (empty token, doubled separator, trailing separator, ...).

    View source

    Members

    new

    fn new(s: &'a str) -> Self
    

    Creates a tokenizer using , as separator and the default error message.

    Source

    with_message

    fn with_message(s: &'a str, exception_message: &'static str) -> Self
    

    Creates a tokenizer using , as separator (the invariant-culture separator) and the given error message.

    Source

    with_separator

    fn with_separator(s: &'a str, separator: char, exception_message: Option<&'static str>) -> Self
    

    Creates a tokenizer with an explicit separator and optional error message.

    Source

    current_token_index

    fn current_token_index(self: &Self) -> Option<usize>
    

    Byte offset of the current token, or None when there is no current token.

    Source

    current_token

    fn current_token(self: &Self) -> Option<&'a str>
    

    The current token, or None when there is no current token.

    Source

    current_token_span

    fn current_token_span(self: &Self) -> &'a str
    

    The current token, or an empty slice when there is no current token.

    Source

    finish

    fn finish(self: &Self) -> Result<(), FormatError>
    

    Verifies that the whole input was consumed.

    This is the counterpart of disposing the tokenizer in the reference implementation and must be called once reading is done.

    Source

    scope

    fn scope<T>(self: Self, f: impl FnOnce(&mut Self) -> Result<T, FormatError>) -> Result<T, FormatError>
    

    Runs f and then finish. An error from finish takes precedence over an error from f, exactly like an exception thrown while leaving a scoped-disposal block replaces the one in flight.

    Source

    try_read_int32

    fn try_read_int32(self: &mut Self) -> Result<Option<i32>, FormatError>
    

    Source

    try_read_int32_with

    fn try_read_int32_with(self: &mut Self, separator: Option<char>) -> Result<Option<i32>, FormatError>
    

    Source

    read_int32

    fn read_int32(self: &mut Self) -> Result<i32, FormatError>
    

    Source

    read_int32_with

    fn read_int32_with(self: &mut Self, separator: Option<char>) -> Result<i32, FormatError>
    

    Source

    try_read_double

    fn try_read_double(self: &mut Self) -> Result<Option<f64>, FormatError>
    

    Source

    try_read_double_with

    fn try_read_double_with(self: &mut Self, separator: Option<char>) -> Result<Option<f64>, FormatError>
    

    Source

    read_double

    fn read_double(self: &mut Self) -> Result<f64, FormatError>
    

    Source

    read_double_with

    fn read_double_with(self: &mut Self, separator: Option<char>) -> Result<f64, FormatError>
    

    Source

    try_read_string

    fn try_read_string(self: &mut Self) -> Result<Option<&'a str>, FormatError>
    

    Same as try_read_span; tokens are borrowed slices.

    Source

    try_read_string_with

    fn try_read_string_with(self: &mut Self, separator: Option<char>) -> Result<Option<&'a str>, FormatError>
    

    Source

    read_string

    fn read_string(self: &mut Self) -> Result<&'a str, FormatError>
    

    Same as read_span; tokens are borrowed slices.

    Source

    read_string_with

    fn read_string_with(self: &mut Self, separator: Option<char>) -> Result<&'a str, FormatError>
    

    Source

    try_read_span

    fn try_read_span(self: &mut Self) -> Result<Option<&'a str>, FormatError>
    

    Source

    try_read_span_with

    fn try_read_span_with(self: &mut Self, separator: Option<char>) -> Result<Option<&'a str>, FormatError>
    

    Source

    read_span

    fn read_span(self: &mut Self) -> Result<&'a str, FormatError>
    

    Source

    read_span_with

    fn read_span_with(self: &mut Self, separator: Option<char>) -> Result<&'a str, FormatError>
    

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ErasedDestructor
    • IntoEither
    • Clone
    • Debug

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.