Struct ctf::parse::PacketParser
source · [−]pub struct PacketParser<'cxt, 'data, Endian> { /* private fields */ }
Expand description
Packet parser.
Thin wrapper around a RawParser
over the bytes of the events of the packet. Also stores the
packet header. Note that the bytes for the header are not included in the parser’s data. It has
already been parsed.
Implementations
Methods from Deref<Target = RawParser<'data>>
sourcepub fn real_position(&self) -> (usize, usize)
pub fn real_position(&self) -> (usize, usize)
Yields the current position and the total length of the input text.
sourcepub fn u8_le(&mut self) -> Res<u8>
pub fn u8_le(&mut self) -> Res<u8>
Parses a u8
.
Examples
let data = 213u8.to_le_bytes();
let mut parser = RawParser::new(&data, 0);
assert_eq!(parser.u8_le().unwrap(), 213);
assert!(parser.is_eof());
sourcepub fn u8_be(&mut self) -> Res<u8>
pub fn u8_be(&mut self) -> Res<u8>
Parses a u8
.
Examples
let data = 213u8.to_be_bytes();
let mut parser = RawParser::new(&data, 0);
assert_eq!(parser.u8_be().unwrap(), 213);
assert!(parser.is_eof());
sourcepub fn u16_le(&mut self) -> Res<u16>
pub fn u16_le(&mut self) -> Res<u16>
Parses a u16
.
Examples
let data = 1_213u16.to_le_bytes();
let mut parser = RawParser::new(&data, 0);
assert_eq!(parser.u16_le().unwrap(), 1_213);
assert!(parser.is_eof());
sourcepub fn u16_be(&mut self) -> Res<u16>
pub fn u16_be(&mut self) -> Res<u16>
Parses a u16
.
Examples
let data = 1_213u16.to_be_bytes();
let mut parser = RawParser::new(&data, 0);
assert_eq!(parser.u16_be().unwrap(), 1_213);
assert!(parser.is_eof());
sourcepub fn u32_le(&mut self) -> Res<u32>
pub fn u32_le(&mut self) -> Res<u32>
Parses a u32
.
Examples
let data = 1_701_213u32.to_le_bytes();
let mut parser = RawParser::new(&data, 0);
assert_eq!(parser.u32_le().unwrap(), 1_701_213);
assert!(parser.is_eof());
sourcepub fn u32_be(&mut self) -> Res<u32>
pub fn u32_be(&mut self) -> Res<u32>
Parses a u32
.
Examples
let data = 1_701_213u32.to_be_bytes();
let mut parser = RawParser::new(&data, 0);
assert_eq!(parser.u32_be().unwrap(), 1_701_213);
assert!(parser.is_eof());
sourcepub fn u64_be(&mut self) -> Res<u64>
pub fn u64_be(&mut self) -> Res<u64>
Parses a u64
.
Examples
let data = 7_501_701_213u64.to_be_bytes();
let mut parser = RawParser::new(&data, 0);
assert_eq!(parser.u64_be().unwrap(), 7_501_701_213);
assert!(parser.is_eof());
sourcepub fn u64_le(&mut self) -> Res<u64>
pub fn u64_le(&mut self) -> Res<u64>
Parses a u64
, low-endian version.
Examples
let data = 7_501_701_213u64.to_le_bytes();
let mut parser = RawParser::new(&data, 0);
assert_eq!(parser.u64_le().unwrap(), 7_501_701_213);
assert!(parser.is_eof());
sourcepub fn f64_be(&mut self) -> Res<f64>
pub fn f64_be(&mut self) -> Res<f64>
Parses a u64
, big-endian version.
Examples
let data = 7_501_701.745f64.to_be_bytes();
let mut parser = RawParser::new(&data, 0);
assert_eq!(parser.f64_be().unwrap(), 7_501_701.745);
assert!(parser.is_eof());
Trait Implementations
sourceimpl<'cxt, 'data, Endian> Deref for PacketParser<'cxt, 'data, Endian>
impl<'cxt, 'data, Endian> Deref for PacketParser<'cxt, 'data, Endian>
Auto Trait Implementations
impl<'cxt, 'data, Endian> RefUnwindSafe for PacketParser<'cxt, 'data, Endian> where
Endian: RefUnwindSafe,
impl<'cxt, 'data, Endian> Send for PacketParser<'cxt, 'data, Endian> where
Endian: Send,
impl<'cxt, 'data, Endian> Sync for PacketParser<'cxt, 'data, Endian> where
Endian: Sync,
impl<'cxt, 'data, Endian> Unpin for PacketParser<'cxt, 'data, Endian> where
Endian: Unpin,
'data: 'cxt,
impl<'cxt, 'data, Endian> !UnwindSafe for PacketParser<'cxt, 'data, Endian>
Blanket Implementations
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
Scheme: ApproxScheme,
type Err = NoError
type Err = NoError
The error type produced by a failed conversion.
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src where
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src where
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ConvUtil for T
impl<T> ConvUtil for T
fn approx_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, DefaultApprox>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, DefaultApprox>,
Approximate the subject to a given type with the default scheme.
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Approximate the subject to a given type with a specific scheme.
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
impl<Src> ValueFrom<Src> for Src
impl<Src> ValueFrom<Src> for Src
type Err = NoError
type Err = NoError
The error type produced by a failed conversion.
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
Convert the given value into an exactly equivalent representation.
impl<Src, Dst> ValueInto<Dst> for Src where
Dst: ValueFrom<Src>,
impl<Src, Dst> ValueInto<Dst> for Src where
Dst: ValueFrom<Src>,
type Err = <Dst as ValueFrom<Src>>::Err
type Err = <Dst as ValueFrom<Src>>::Err
The error type produced by a failed conversion.
fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
Convert the subject into an exactly equivalent representation.