socket_filter

Struct TransmitCounter

source
pub struct TransmitCounter { /* private fields */ }

Implementations§

source§

impl TransmitCounter

source

pub fn get_egress(&self) -> u64

Get the number of bytes transmitted.

Examples found in repository?
examples/ex_socket_filter.rs (line 12)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fn main() {
    let open_object = Box::leak(Box::new(MaybeUninit::uninit()));
    let socket_filter = socket_filter::TransmitCounter::new(
        &["lo", "podman", "veth", "flannel", "cni0", "utun"],
        open_object,
    );
    loop {
        println!(
            "current bytes: {} {}",
            socket_filter.get_egress(),
            socket_filter.get_ingress()
        );
        sleep(Duration::from_secs(1));
    }
}
source

pub fn get_ingress(&self) -> u64

Get the number of bytes received.

Examples found in repository?
examples/ex_socket_filter.rs (line 13)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fn main() {
    let open_object = Box::leak(Box::new(MaybeUninit::uninit()));
    let socket_filter = socket_filter::TransmitCounter::new(
        &["lo", "podman", "veth", "flannel", "cni0", "utun"],
        open_object,
    );
    loop {
        println!(
            "current bytes: {} {}",
            socket_filter.get_egress(),
            socket_filter.get_ingress()
        );
        sleep(Duration::from_secs(1));
    }
}
source

pub fn new( ignored_interfaces: &[&'static str], open_object: &'static mut MaybeUninit<OpenObject>, ) -> Self

Create a new TransmitCounter instance. ignored_interfaces is a list of interface names to ignore.

Examples found in repository?
examples/ex_socket_filter.rs (lines 5-8)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fn main() {
    let open_object = Box::leak(Box::new(MaybeUninit::uninit()));
    let socket_filter = socket_filter::TransmitCounter::new(
        &["lo", "podman", "veth", "flannel", "cni0", "utun"],
        open_object,
    );
    loop {
        println!(
            "current bytes: {} {}",
            socket_filter.get_egress(),
            socket_filter.get_ingress()
        );
        sleep(Duration::from_secs(1));
    }
}

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> 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, 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.