Skip to main content

NetworkLayerHandler

Struct NetworkLayerHandler 

Source
pub struct NetworkLayerHandler {
    pub local_network: u16,
    pub routers: Vec<RouterInfo>,
    pub stats: NetworkStatistics,
    /* private fields */
}
Expand description

Network layer message handler

Fields§

§local_network: u16

Local network number

§routers: Vec<RouterInfo>

Router information cache

§stats: NetworkStatistics

Network statistics

Implementations§

Source§

impl NetworkLayerHandler

Source

pub fn new(local_network: u16) -> Self

Create a new network layer handler

Source

pub fn process_npdu( &mut self, npdu: &Npdu, source_address: &NetworkAddress, ) -> Result<Option<NetworkResponse>>

Process an incoming NPDU

Source

pub fn who_is_router(&mut self, _network: Option<u16>) -> Npdu

Send Who-Is-Router-To-Network message

Source

pub fn i_am_router(&mut self, _networks: &[u16]) -> Npdu

Send I-Am-Router-To-Network message

Source

pub fn update_router(&mut self, router_info: RouterInfo)

Update router information

Source

pub fn find_router(&self, network: u16) -> Option<&RouterInfo>

Find best router for a network

Trait Implementations§

Source§

impl Debug for NetworkLayerHandler

Source§

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

Formats the value using the given formatter. Read more

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.