Leases

Struct Leases 

Source
pub struct Leases { /* private fields */ }
Expand description

Used to manage the dynamic collection of IP addresses that the server leases.

Implementations§

Source§

impl Leases

Source

pub const FILE_NAME: &'static str = "toe-beans-leases.toml"

The file name that the Leases is read from and written to.

Source

pub fn new(config: &Config) -> Self

Depending on whether the passed Config enables use_leases_file: Restore and validate the leases file or create a new, empty Leases.

Source

pub fn offer( &mut self, owner: MacAddress, requested_ip: Option<Ipv4Addr>, ) -> Result<Ipv4Addr>

Takes an available IP address, marks it as offered, and returns it.

Returns one of:

  • The previously offered address, if one has been offered.
  • The requested address:
    • If one was requested,
    • and it is available,
    • and there is not a static lease
  • Otherwise any available address (unless none are available).
Source

pub fn ack(&mut self, owner: MacAddress) -> Result<Ipv4Addr>

Takes a chaddr’s offered ip address and marks it as reserved then commits it to persistent storage and returns the address.

Source

pub fn extend(&mut self, owner: MacAddress) -> Result<()>

Resets the time of an offered or acked lease. Used by the server in the lease renew/rebind process.

Source

pub fn release(&mut self, owner: MacAddress) -> Result<()>

Makes an ip address that was offered or acked available again.

Source

pub fn is_available(&self, ip: &Ipv4Addr) -> bool

Checks whether the passed IP address is available in the pool.

Source

pub fn verify_lease(&self, owner: MacAddress, ip: &Ipv4Addr) -> Result<()>

Checks if the passed IP address matches the committed, leased IP address, and that the lease is not expired.

Trait Implementations§

Source§

impl<'de> Deserialize<'de> for Leases

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Leases

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Leases

§

impl RefUnwindSafe for Leases

§

impl Send for Leases

§

impl Sync for Leases

§

impl Unpin for Leases

§

impl UnwindSafe for Leases

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,