Trait untrustended::ReaderExt[][src]

pub trait ReaderExt<'a> {
Show methods fn read_byte(&mut self) -> Result<u8, EndOfInput>;
fn read_bytes(&mut self, num_bytes: usize) -> Result<Input<'a>, EndOfInput>;
fn read_be<T: FromReader>(&mut self) -> Result<T, Error>;
fn read_le<T: FromReader>(&mut self) -> Result<T, Error>; fn read_u8(&mut self) -> Result<u8, Error> { ... }
fn read_u16be(&mut self) -> Result<u16, Error> { ... }
fn read_u24be(&mut self) -> Result<u32, Error> { ... }
fn read_u32be(&mut self) -> Result<u32, Error> { ... }
fn read_u48be(&mut self) -> Result<u64, Error> { ... }
fn read_u64be(&mut self) -> Result<u64, Error> { ... }
fn read_u128be(&mut self) -> Result<u128, Error> { ... }
fn read_u16le(&mut self) -> Result<u16, Error> { ... }
fn read_u24le(&mut self) -> Result<u32, Error> { ... }
fn read_u32le(&mut self) -> Result<u32, Error> { ... }
fn read_u48le(&mut self) -> Result<u64, Error> { ... }
fn read_u64le(&mut self) -> Result<u64, Error> { ... }
fn read_u128le(&mut self) -> Result<u128, Error> { ... }
fn read_i8(&mut self) -> Result<i8, Error> { ... }
fn read_i16be(&mut self) -> Result<i16, Error> { ... }
fn read_i24be(&mut self) -> Result<i32, Error> { ... }
fn read_i32be(&mut self) -> Result<i32, Error> { ... }
fn read_i48be(&mut self) -> Result<i64, Error> { ... }
fn read_i64be(&mut self) -> Result<i64, Error> { ... }
fn read_i128be(&mut self) -> Result<i128, Error> { ... }
fn read_i16le(&mut self) -> Result<i16, Error> { ... }
fn read_i24le(&mut self) -> Result<i32, Error> { ... }
fn read_i32le(&mut self) -> Result<i32, Error> { ... }
fn read_i48le(&mut self) -> Result<i64, Error> { ... }
fn read_i64le(&mut self) -> Result<i64, Error> { ... }
fn read_i128le(&mut self) -> Result<i128, Error> { ... }
fn read_bytes_less_safe(
        &mut self,
        num_bytes: usize
    ) -> Result<&'a [u8], Error> { ... }
fn read_utf8(&mut self, num_bytes: usize) -> Result<&'a str, Error> { ... }
fn read_utf16(&mut self, num_bytes: usize) -> Result<String, Error> { ... }
fn read_ipv4addr(&mut self) -> Result<Ipv4Addr, Error> { ... }
fn read_ipv6addr(&mut self) -> Result<Ipv6Addr, Error> { ... }
}
Expand description

A trait extending untrusted’s Reader.

Required methods

Read one byte.

Skips num_bytes of the input, returning the skipped input as an Input.

Returns Ok(i) where i is an Input if there are at least num_bytes of input remaining, and Err(EndOfInput) otherwise.

Read as many bytes as needed to instantiate a type in Big Endian byte order.

Read as many bytes as needed to instantiate a type in Little Endian byte order.

Provided methods

Reads 8 bit unsigned integer.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader is at the end of the input.

Reads 16 bit unsigned integer in big endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 24 bit unsigned integer in big endian.

This method reads three bytes, but returns u32 because Rust doesn’t have 24 bit integer type.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 32 bit unsigned integer in big endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 48 bit unsigned integer in big endian.

This method reads six bytes, but returns u64 because Rust doesn’t have 48 bit integer type.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 64 bit unsigned integer in big endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 128 bit unsigned integer in big endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 16 bit unsigned integer in little endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 24 bit unsigned integer in little endian.

This method reads three bytes, but returns u32 because Rust doesn’t have 24 bit integer type.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 32 bit unsigned integer in little endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 48 bit unsigned integer in little endian.

This method reads six bytes, but returns u64 because Rust doesn’t have 48 bit integer type.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 64 bit unsigned integer in little endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 128 bit unsigned integer in little endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 8 bit signed integer.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader is at the end of the input.

Reads 16 bit signed integer in big endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 24 bit signed integer in big endian.

This method reads three bytes, but returns i32 because Rust doesn’t have 24 bit integer type.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 32 bit signed integer in big endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 48 bit signed integer in big endian.

This method reads six bytes, but returns i64 because Rust doesn’t have 48 bit integer type.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 64 bit signed integer in big endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 128 bit signed integer in big endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 16 bit signed integer in little endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 24 bit signed integer in little endian.

This method reads three bytes, but returns i32 because Rust doesn’t have 24 bit integer type.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 32 bit signed integer in little endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 48 bit signed integer in little endian.

This method reads six bytes, but returns i64 because Rust doesn’t have 48 bit integer type.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 64 bit signed integer in little endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads 128 bit signed integer in little endian.

Returns Ok(v) where v is the value read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads given amount of bytes.

Access the given amount of bytes as a slice so it can be processed by functions that are not written using the untrusted’s Input/Reader framework.

Returns Ok(v) where v is a &[u8] of bytes read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading.

Reads bytes as UTF-8 String.

Length required is the amount of bytes to read, not the amount of UTF-8 characters.

Read bytes are validated to be valid UTF-8 by str::from_utf8 method.

Returns Ok(v) where v is a &str of bytes read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading, or Err(Error::ParseError) if UTF-8 parsing failed.

Reads bytes as UTF-16 String.

Length is the amount of bytes to read, not the amount of UTF-16 characters. Length should be even number and Err(Error::ParseError) is returned if it’s odd.

Read bytes are validated to be valid UTF-16 by String::from_utf16 method.

Returns Ok(v) where v is a String of bytes read, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading, or Err(Error::ParseError) if UTF-8 parsing failed.

Reads IPv4 address in big endian format.

Returns Ok(v) where v is a Ipv4Addr, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading, or Err(Error::ParseError) if parsing of address failed.

Reads IPv6 address in big endian format.

Returns Ok(v) where v is a Ipv6Addr, or Err(Error::EndOfInput) if the Reader encountered an end of the input while reading, or Err(Error::ParseError) if parsing of address failed.

Implementations on Foreign Types

Implementors