Struct Parser

Source
struct Parser<'a> {
    state: &'a [u8],
}

Fields§

§state: &'a [u8]

Implementations§

Source§

impl<'a> Parser<'a>

Source

fn new(input: &'a [u8]) -> Parser<'a>

Source

fn read_atomically<T, F>(&mut self, inner: F) -> Option<T>
where F: FnOnce(&mut Parser<'_>) -> Option<T>,

Run a parser, and restore the pre-parse state if it fails.

Source

fn parse_with<T, F>( &mut self, inner: F, kind: AddrKind, ) -> Result<T, AddrParseError>
where F: FnOnce(&mut Parser<'_>) -> Option<T>,

Run a parser, but fail if the entire input wasn’t consumed. Doesn’t run atomically.

Source

fn peek_char(&self) -> Option<char>

Peek the next character from the input

Source

fn read_char(&mut self) -> Option<char>

Reads the next character from the input

Source

fn read_given_char(&mut self, target: char) -> Option<()>

Reads the next character from the input if it matches the target.

Source

fn read_separator<T, F>( &mut self, sep: char, index: usize, inner: F, ) -> Option<T>
where F: FnOnce(&mut Parser<'_>) -> Option<T>,

Helper for reading separators in an indexed loop. Reads the separator character iff index > 0, then runs the parser. When used in a loop, the separator character will only be read on index > 0 (see read_ipv4_addr for an example)

Source

fn read_number<T: ReadNumberHelper + TryFrom<u32>>( &mut self, radix: u32, max_digits: Option<usize>, allow_zero_prefix: bool, ) -> Option<T>

Source

fn read_ipv4_addr(&mut self) -> Option<Ipv4Addr>

Reads an IPv4 address.

Source

fn read_ipv6_addr(&mut self) -> Option<Ipv6Addr>

Reads an IPv6 address.

Source

fn read_ip_addr(&mut self) -> Option<IpAddr>

Reads an IP address, either IPv4 or IPv6.

Source

fn read_port(&mut self) -> Option<u16>

Reads a : followed by a port in base 10.

Source

fn read_scope_id(&mut self) -> Option<u32>

Reads a % followed by a scope ID in base 10.

Source

fn read_socket_addr_v4(&mut self) -> Option<SocketAddrV4>

Reads an IPv4 address with a port.

Source

fn read_socket_addr_v6(&mut self) -> Option<SocketAddrV6>

Reads an IPv6 address with a port.

Source

fn read_socket_addr(&mut self) -> Option<SocketAddr>

Reads an IP address with a port.

Auto Trait Implementations§

§

impl<'a> Freeze for Parser<'a>

§

impl<'a> RefUnwindSafe for Parser<'a>

§

impl<'a> Send for Parser<'a>

§

impl<'a> Sync for Parser<'a>

§

impl<'a> Unpin for Parser<'a>

§

impl<'a> UnsafeUnpin for Parser<'a>

§

impl<'a> UnwindSafe for Parser<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SizedTypeProperties for T

Source§

#[doc(hidden)] const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
Source§

#[doc(hidden)] const LAYOUT: Layout = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)] const MAX_SLICE_LEN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
The largest safe length for a [Self]. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.