# CharacterReader

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

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

```rust
struct CharacterReader<'a>
```

A forward-only reader over a string.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/character_reader.rs#L120)

## Members

- [`parse_arguments`](#function-parse_arguments)
- [`parse_arguments_with_delimiter`](#function-parse_arguments_with_delimiter)
- [`new`](#function-new)
- [`end`](#function-end)
- [`peek`](#function-peek)
- [`position`](#function-position)
- [`take`](#function-take)
- [`skip_whitespace`](#function-skip_whitespace)
- [`take_if`](#function-take_if)
- [`take_if_str`](#function-take_if_str)
- [`take_if_fn`](#function-take_if_fn)
- [`take_until`](#function-take_until)
- [`take_while`](#function-take_while)
- [`try_peek`](#function-try_peek)
- [`peek_whitespace`](#function-peek_whitespace)
- [`skip`](#function-skip)
- [`parse_identifier`](#function-parse_identifier)
- [`parse_type_identifier`](#function-parse_type_identifier)
- [`parse_number`](#function-parse_number)
- [`check_keyword`](#function-check_keyword)
- [`take_if_keyword`](#function-take_if_keyword)
- [`parse_style_class`](#function-parse_style_class)

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

### parse_arguments

```rust
fn parse_arguments(self: &mut Self, open: char, close: char) -> Result<Vec<String>, ExpressionParseError>
```

Parses a list of arguments enclosed in `open`/`close` and separated by
`,`. The reader must be positioned on `open`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/core/parsers/argument_list_parser.rs#L9)

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

### parse_arguments_with_delimiter

```rust
fn parse_arguments_with_delimiter(self: &mut Self, open: char, close: char, delimiter: char) -> Result<Vec<String>, ExpressionParseError>
```

Parses a list of arguments enclosed in `open`/`close` and separated by
`delimiter`. The reader must be positioned on `open`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/core/parsers/argument_list_parser.rs#L19)

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

### new

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

Creates a reader positioned at the start of `s`.

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

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

### end

```rust
fn end(self: &Self) -> bool
```

Gets a value indicating whether the whole input has been consumed.

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

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

### peek

```rust
fn peek(self: &Self) -> Option<char>
```

Gets the next character without consuming it, or `None` at the end.

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

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

### position

```rust
fn position(self: &Self) -> i32
```

Gets the number of characters consumed so far.

As upstream, `Self::skip` does not advance the position.

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

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

### take

```rust
fn take(self: &mut Self) -> Option<char>
```

Consumes and returns the next character, or returns `None` at the end.

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

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

### skip_whitespace

```rust
fn skip_whitespace(self: &mut Self)
```

Consumes leading white space.

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

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

### take_if

```rust
fn take_if(self: &mut Self, c: char) -> bool
```

Consumes the next character if it equals `c`.

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

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

### take_if_str

```rust
fn take_if_str(self: &mut Self, s: &str) -> bool
```

Consumes `s` if the remaining input starts with it.

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

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

### take_if_fn

```rust
fn take_if_fn(self: &mut Self, condition: impl Fn(char) -> bool) -> bool
```

Consumes the next character if it satisfies `condition`.

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

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

### take_until

```rust
fn take_until(self: &mut Self, c: char) -> &'a str
```

Consumes and returns everything up to (not including) the first `c`,
or the rest of the input when `c` does not occur.

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

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

### take_while

```rust
fn take_while(self: &mut Self, condition: impl Fn(char) -> bool) -> &'a str
```

Consumes and returns the longest prefix whose characters all satisfy
`condition`.

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

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

### try_peek

```rust
fn try_peek(self: &Self, count: usize) -> &'a str
```

Returns the next `count` characters without consuming them, or an empty
string when fewer than `count` characters remain.

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

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

### peek_whitespace

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

Returns the leading white space without consuming it.

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

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

### skip

```rust
fn skip(self: &mut Self, count: usize)
```

Consumes `count` characters without advancing `Self::position`
(as upstream).
## Panics

Panics when fewer than `count` characters remain; callers skip only
what they have peeked.

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

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

### parse_identifier

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

Parses an identifier: a letter or `_` followed by letters, `_`, marks,
connector punctuation, format characters and decimal digits. Returns an
empty string (consuming nothing) when the input does not start with an
identifier.

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

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

### parse_type_identifier

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

Parses an identifier that may name a nested type, e.g. "Outer+Inner".

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

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

### parse_number

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

Parses a run of decimal digits (possibly empty).

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

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

### check_keyword

```rust
fn check_keyword(self: &Self, keyword: &str) -> bool
```

Checks whether the input continues with optional white space followed
by `keyword`, without consuming anything.

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

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

### take_if_keyword

```rust
fn take_if_keyword(self: &mut Self, keyword: &str) -> bool
```

Consumes optional white space followed by `keyword` if the input
continues with it.

As upstream, the consumed characters are skipped without advancing
`CharacterReader::position`.

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

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

### parse_style_class

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

Parses a style class name: an identifier that may also contain `-`.
Returns an empty string (consuming nothing) when the input does not
start with a class name.

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

## 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/).
