Client

Struct Client 

Source
pub struct Client<T> {
    pub rng: T,
    pub mac: [u8; 6],
}
Expand description

A simple DHCP client. The client is unaware of the IP/UDP transport layer and operates purely in terms of packets represented as Rust slices.

As such, the client can generate all BOOTP requests and parse BOOTP replies.

Fields§

§rng: T§mac: [u8; 6]

Implementations§

Source§

impl<T> Client<T>
where T: RngCore,

Source

pub const fn new(rng: T, mac: [u8; 6]) -> Self

Source

pub fn discover<'o>( &mut self, opt_buf: &'o mut [DhcpOption<'o>], secs: u16, ip: Option<Ipv4Addr>, ) -> (Packet<'o>, u32)

Source

pub fn request<'o>( &mut self, opt_buf: &'o mut [DhcpOption<'o>], secs: u16, ip: Ipv4Addr, broadcast: bool, ) -> (Packet<'o>, u32)

Source

pub fn release<'o>( &mut self, opt_buf: &'o mut [DhcpOption<'o>], secs: u16, ip: Ipv4Addr, ) -> Packet<'o>

Source

pub fn decline<'o>( &mut self, opt_buf: &'o mut [DhcpOption<'o>], secs: u16, ip: Ipv4Addr, ) -> Packet<'o>

Source

pub fn is_offer(&self, reply: &Packet<'_>, xid: u32) -> bool

Source

pub fn is_ack(&self, reply: &Packet<'_>, xid: u32) -> bool

Source

pub fn is_nak(&self, reply: &Packet<'_>, xid: u32) -> bool

Source

pub fn bootp_request<'o>( &mut self, secs: u16, ip: Option<Ipv4Addr>, broadcast: bool, options: Options<'o>, ) -> (Packet<'o>, u32)

Source

pub fn is_bootp_reply_for_us( &self, reply: &Packet<'_>, xid: u32, expected_message_types: Option<&[MessageType]>, ) -> bool

Auto Trait Implementations§

§

impl<T> Freeze for Client<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Client<T>
where T: RefUnwindSafe,

§

impl<T> Send for Client<T>
where T: Send,

§

impl<T> Sync for Client<T>
where T: Sync,

§

impl<T> Unpin for Client<T>
where T: Unpin,

§

impl<T> UnwindSafe for Client<T>
where T: UnwindSafe,

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.