Struct dhcpv4::server::Server

source ·
pub struct Server<DS: DataStore, TS: SystemTimeSource = StdSystemTime> { /* private fields */ }
Expand description

A minimal DHCP server.

This comment will be expanded upon in future CLs as the server design is iterated upon.

Implementations§

source§

impl<DS: DataStore, TS: SystemTimeSource> Server<DS, TS>

source

pub fn new_from_state( store: DS, params: ServerParameters, options_repo: HashMap<OptionCode, DhcpOption>, records: ClientRecords ) -> Result<Self, Error>

Attempts to instantiate a new Server value from the persisted state contained in the provided parts. If the client leases and address pool contained in the provided parts are inconsistent with one another, then instantiation will fail.

source

pub fn new_with_time_source( store: DS, params: ServerParameters, options_repo: HashMap<OptionCode, DhcpOption>, records: ClientRecords, time_source: TS ) -> Result<Self, Error>

source

pub fn new(store: Option<DS>, params: ServerParameters) -> Self

Instantiates a new Server, without persisted state, from the supplied parameters.

source

pub fn dispatch(&mut self, msg: Message) -> Result<ServerAction, ServerError>

Dispatches an incoming DHCP message to the appropriate handler for processing.

If the incoming message is a valid client DHCP message, then the server will attempt to take appropriate action to serve the client’s request, update the internal server state, and return the suitable response. If the incoming message is invalid, or the server is unable to serve the request, or the processing of the client’s request resulted in an error, then dispatch() will return the fitting Err indicating what went wrong.

Trait Implementations§

source§

impl<DS: DataStore, TS: SystemTimeSource> ServerDispatcher for Server<DS, TS>

source§

fn try_validate_parameters(&self) -> Result<&ServerParameters, Status>

Validates the current set of server parameters returning a reference to the parameters if the configuration is valid or an error otherwise.
source§

fn dispatch_get_option(&self, code: OptionCode) -> Result<Option_, Status>

Retrieves the stored DHCP option value that corresponds to the OptionCode argument.
source§

fn dispatch_get_parameter( &self, name: ParameterName ) -> Result<Parameter, Status>

Retrieves the stored DHCP server parameter value that corresponds to the ParameterName argument.
source§

fn dispatch_set_option(&mut self, value: Option_) -> Result<(), Status>

Updates the stored DHCP option value to the argument.
source§

fn dispatch_set_parameter(&mut self, value: Parameter) -> Result<(), Status>

Updates the stored DHCP server parameter to the argument.
source§

fn dispatch_list_options(&self) -> Result<Vec<Option_>, Status>

Retrieves all of the stored DHCP option values.
source§

fn dispatch_list_parameters(&self) -> Result<Vec<Parameter>, Status>

Retrieves all of the stored DHCP parameter values.
source§

fn dispatch_reset_options(&mut self) -> Result<(), Status>

Resets all DHCP options to have no value.
source§

fn dispatch_reset_parameters( &mut self, defaults: &ServerParameters ) -> Result<(), Status>

Resets all DHCP server parameters to their default values in defaults.
source§

fn dispatch_clear_leases(&mut self) -> Result<(), Status>

Clears all leases from the store maintained by the ServerDispatcher.

Auto Trait Implementations§

§

impl<DS, TS> Freeze for Server<DS, TS>
where TS: Freeze, DS: Freeze,

§

impl<DS, TS> RefUnwindSafe for Server<DS, TS>

§

impl<DS, TS> Send for Server<DS, TS>
where TS: Send, DS: Send,

§

impl<DS, TS> Sync for Server<DS, TS>
where TS: Sync, DS: Sync,

§

impl<DS, TS> Unpin for Server<DS, TS>
where TS: Unpin, DS: Unpin,

§

impl<DS, TS> UnwindSafe for Server<DS, TS>
where TS: UnwindSafe, DS: 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
§

impl<T> Encode<Ambiguous1> for T

§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _offset: usize, _depth: Depth ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T> Encode<Ambiguous2> for T

§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _offset: usize, _depth: Depth ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> IntoAny for T
where T: 'static + Send + Sync,

§

fn into_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Cast the given object into a dyn std::any::Any.
§

impl<T, U> IntoExt<U> for T
where U: FromExt<T>,

§

fn into_ext(self) -> U

Performs the conversion.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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

§

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

impl<T, U> TryIntoExt<U> for T
where U: TryFromExt<T>,

§

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

§

fn try_into_ext(self) -> Result<U, <T as TryIntoExt<U>>::Error>

Tries to perform the conversion.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more