Struct CycleStart

Source
pub struct CycleStart {
    pub length: u32,
    pub cycle_id: u32,
    pub list_id: u32,
    pub cycle_id_human: u32,
    pub start_time: u32,
    pub flags: Flags,
    pub param_length: Option<u16>,
    pub stop_time: Option<u32>,
    pub hostname: Option<CString>,
}
Expand description

A start record denotes the starting point for a new cycle.

Fields§

§length: u32§cycle_id: u32

Cycle ID, assigned by warts from a counter.

§list_id: u32

List ID, referencing the list this cycle is over.

§cycle_id_human: u32

Cycle ID, assigned by a human.

§start_time: u32

Start time of the cycle, seconds since Unix epoch.

§flags: Flags

Flags.

§param_length: Option<u16>

Parameter length, included if any flags are set.

§stop_time: Option<u32>

Stop time of the cycle in seconds since Unix epoch, included if flag 1 is set.

§hostname: Option<CString>

Hostname at cycle start point, included if flag 2 is set.

Implementations§

Source§

impl CycleStart

Source

pub fn finalize(self) -> Self

Examples found in repository?
examples/write_traceroute.rs (line 41)
12fn main() -> io::Result<()> {
13    let list_name = CString::new("default").unwrap();
14    let hostname = CString::new("ubuntu-linux-20-04-desktop").unwrap();
15
16    let list = List {
17        length: 0,
18        list_id: 1,
19        list_id_human: 0,
20        name: list_name.clone(),
21        flags: Default::default(),
22        param_length: None,
23        description: Some(list_name.clone()),
24        monitor_name: None,
25    };
26    // The `finalize()` method computes and set the flags and length fields.
27    io::stdout().write_all(&Object::List(list.finalize()).to_bytes().unwrap())?;
28
29    let cycle_start = CycleStart {
30        length: 0,
31        cycle_id: 1,
32        list_id: 1,
33        cycle_id_human: 0,
34        start_time: Utc::now().timestamp() as u32,
35        flags: Default::default(),
36        param_length: None,
37        stop_time: None,
38        hostname: Some(hostname),
39    };
40    io::stdout().write_all(
41        &Object::CycleStart(cycle_start.finalize())
42            .to_bytes()
43            .unwrap(),
44    )?;
45
46    let tp = TraceProbe {
47        flags: Default::default(),
48        param_length: None,
49        addr_id: None,
50        probe_ttl: Some(1),
51        reply_ttl: Some(254),
52        hop_flags: Some(17),
53        probe_id: Some(0),
54        rtt_usec: Some(1057),
55        icmp_type: Some(11),
56        icmp_code: Some(0),
57        probe_size: Some(44),
58        reply_size: Some(56),
59        reply_ip_id: Some(387),
60        reply_ip_tos: Some(0),
61        next_hop_mtu: None,
62        quoted_length: None,
63        quoted_ttl: None,
64        reply_tcp_flags: None,
65        quoted_tos: Some(0),
66        icmp_extensions_length: None,
67        icmp_extensions: vec![],
68        addr: Some(Address::from(Ipv4Addr::new(137, 194, 164, 254))),
69        tx: Some(Timeval::from(Utc::now().naive_utc())),
70    };
71
72    let traceroute = Traceroute {
73        length: 0,
74        flags: Flags::default(),
75        param_length: None,
76        list_id: Some(1),
77        cycle_id: Some(1),
78        src_addr_id: None,
79        dst_addr_id: None,
80        start_time: Some(Timeval::from(Utc::now().naive_utc())),
81        stop_reason: Some(TraceStopReason::Completed),
82        stop_data: Some(0),
83        trace_flags: None,
84        attempts: Some(2),
85        hop_limit: Some(0),
86        trace_type: Some(TraceType::UDPParis),
87        probe_size: Some(44),
88        src_port: Some(57352),
89        dst_port: Some(33435),
90        first_ttl: Some(1),
91        ip_tos: Some(0),
92        timeout_sec: Some(5),
93        allowed_loops: Some(1),
94        hops_probed: Some(7),
95        gap_limit: Some(5),
96        gap_limit_action: Some(TraceGapAction::LastDitch),
97        loop_action: Some(0),
98        probes_sent: Some(8),
99        interval_csec: Some(0),
100        confidence_level: Some(0),
101        src_addr: Some(Address::from(Ipv4Addr::new(137, 194, 165, 109))),
102        dst_addr: Some(Address::from(Ipv4Addr::new(8, 8, 8, 8))),
103        user_id: None,
104        ip_offset: None,
105        router_addr: None,
106        hop_count: 1,
107        hops: vec![tp.finalize()],
108        eof: 0,
109    };
110    io::stdout().write_all(
111        Object::Traceroute(traceroute.finalize())
112            .to_bytes()
113            .unwrap()
114            .as_slice(),
115    )?;
116
117    let cycle_stop = CycleStop {
118        length: 0,
119        cycle_id: 1,
120        stop_time: Utc::now().timestamp() as u32,
121        flags: Default::default(),
122    };
123    io::stdout().write_all(&Object::CycleStop(cycle_stop.finalize()).to_bytes().unwrap())?;
124
125    Ok(())
126}

Trait Implementations§

Source§

impl Debug for CycleStart

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DekuRead<'_, Endian> for CycleStart

Source§

fn read( __deku_input_bits: &BitSlice<u8, Msb0>, endian: Endian, ) -> Result<(&BitSlice<u8, Msb0>, Self), DekuError>

Read bits and construct type Read more
Source§

impl DekuUpdate for CycleStart

Source§

fn update(&mut self) -> Result<(), DekuError>

Apply updates
Source§

impl DekuWrite<Endian> for CycleStart

Source§

fn write( &self, __deku_output: &mut BitVec<u8, Msb0>, endian: Endian, ) -> Result<(), DekuError>

Write type to bits Read more
Source§

impl PartialEq for CycleStart

Source§

fn eq(&self, other: &CycleStart) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for CycleStart

Auto Trait Implementations§

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> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. 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> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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.