Struct Parser

pub(in ::net::parser) struct Parser<'a> { pub(in ::net::parser) state: &'a [u8] }

Fields

state: &'a [u8]

Implementations

impl<'a> Parser<'a>

fn new(input: &'a [u8]) -> Parser<'a>
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.

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.

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

Reads the next character from the input

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

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

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)

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

Reads a number off the front of the input in the given radix, stopping at the first non-digit character or eof. Fails if the number has more digits than max_digits, if there is no number, if the number overflows T, or if there are leading zeros but allow_zero_prefix is false.

max_digits must be in 1..=6.

fn read_decimal<T: ReadNumberHelper>(&mut self) -> Option<T>

Reads a decimal number off the front of the input, stopping at the first non-digit character or eof. Fails if there is no number, or if the number overflows T. Allows an arbitrary amount of leading zeros.

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

Reads an IPv4 address.

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

Reads an IPv6 address.

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

Reads an IP address, either IPv4 or IPv6.

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

Reads a : followed by a port in base 10.

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

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

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

Reads an IPv4 address with a port.

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

Reads an IPv6 address with a port.

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

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

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Parser<'a> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Parser<'a> where T: ?Sized,

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

impl<T> From<T> for Parser<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for Parser<'a> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for Parser<'a>

impl<T, U> Into<U> for Parser<'a> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom<U> for Parser<'a> where U: Into<T>,

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

impl<T, U> TryInto<U> for Parser<'a> where U: TryFrom<T>,

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