# SpanStringTokenizer

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/utilities/span_string_tokenizer/struct-spanstringtokenizer/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L70)

## Members

- [`new`](#function-new)
- [`with_message`](#function-with_message)
- [`with_separator`](#function-with_separator)
- [`current_token_index`](#function-current_token_index)
- [`current_token`](#function-current_token)
- [`current_token_span`](#function-current_token_span)
- [`finish`](#function-finish)
- [`scope`](#function-scope)
- [`try_read_int32`](#function-try_read_int32)
- [`try_read_int32_with`](#function-try_read_int32_with)
- [`read_int32`](#function-read_int32)
- [`read_int32_with`](#function-read_int32_with)
- [`try_read_double`](#function-try_read_double)
- [`try_read_double_with`](#function-try_read_double_with)
- [`read_double`](#function-read_double)
- [`read_double_with`](#function-read_double_with)
- [`try_read_string`](#function-try_read_string)
- [`try_read_string_with`](#function-try_read_string_with)
- [`read_string`](#function-read_string)
- [`read_string_with`](#function-read_string_with)
- [`try_read_span`](#function-try_read_span)
- [`try_read_span_with`](#function-try_read_span_with)
- [`read_span`](#function-read_span)
- [`read_span_with`](#function-read_span_with)

<a id="function-new"></a>

### new

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L83)

<a id="function-with_message"></a>

### with_message

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L90)

<a id="function-with_separator"></a>

### with_separator

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L95)

<a id="function-current_token_index"></a>

### current_token_index

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L112)

<a id="function-current_token"></a>

### current_token

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L118)

<a id="function-current_token_span"></a>

### current_token_span

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L124)

<a id="function-finish"></a>

### finish

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L133)

<a id="function-scope"></a>

### scope

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L144)

<a id="function-try_read_int32"></a>

### try_read_int32

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L154)

<a id="function-try_read_int32_with"></a>

### try_read_int32_with

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L158)

<a id="function-read_int32"></a>

### read_int32

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L169)

<a id="function-read_int32_with"></a>

### read_int32_with

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L173)

<a id="function-try_read_double"></a>

### try_read_double

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L181)

<a id="function-try_read_double_with"></a>

### try_read_double_with

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L185)

<a id="function-read_double"></a>

### read_double

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L196)

<a id="function-read_double_with"></a>

### read_double_with

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L200)

<a id="function-try_read_string"></a>

### try_read_string

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

Same as `try_read_span`; tokens are borrowed slices.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L209)

<a id="function-try_read_string_with"></a>

### try_read_string_with

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L214)

<a id="function-read_string"></a>

### read_string

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

Same as `read_span`; tokens are borrowed slices.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L223)

<a id="function-read_string_with"></a>

### read_string_with

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L228)

<a id="function-try_read_span"></a>

### try_read_span

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L233)

<a id="function-try_read_span_with"></a>

### try_read_span_with

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L237)

<a id="function-read_span"></a>

### read_span

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L246)

<a id="function-read_span_with"></a>

### read_span_with

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/span_string_tokenizer.rs#L250)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-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](/docs/0.5.0/api/).
