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>
impl<DS: DataStore, TS: SystemTimeSource> Server<DS, TS>
Sourcepub fn new_from_state(
store: DS,
params: ServerParameters,
options_repo: HashMap<OptionCode, DhcpOption>,
records: ClientRecords,
) -> Result<Self, Error>
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.
pub fn new_with_time_source( store: DS, params: ServerParameters, options_repo: HashMap<OptionCode, DhcpOption>, records: ClientRecords, time_source: TS, ) -> Result<Self, Error>
Sourcepub fn new(store: Option<DS>, params: ServerParameters) -> Self
pub fn new(store: Option<DS>, params: ServerParameters) -> Self
Instantiates a new Server
, without persisted state, from the supplied parameters.
Sourcepub fn dispatch(&mut self, msg: Message) -> Result<ServerAction, ServerError>
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>
impl<DS: DataStore, TS: SystemTimeSource> ServerDispatcher for Server<DS, TS>
Source§fn try_validate_parameters(&self) -> Result<&ServerParameters, Status>
fn try_validate_parameters(&self) -> Result<&ServerParameters, Status>
Source§fn dispatch_get_option(&self, code: OptionCode) -> Result<Option_, Status>
fn dispatch_get_option(&self, code: OptionCode) -> Result<Option_, Status>
Source§fn dispatch_get_parameter(
&self,
name: ParameterName,
) -> Result<Parameter, Status>
fn dispatch_get_parameter( &self, name: ParameterName, ) -> Result<Parameter, Status>
Source§fn dispatch_set_option(&mut self, value: Option_) -> Result<(), Status>
fn dispatch_set_option(&mut self, value: Option_) -> Result<(), Status>
Source§fn dispatch_set_parameter(&mut self, value: Parameter) -> Result<(), Status>
fn dispatch_set_parameter(&mut self, value: Parameter) -> Result<(), Status>
Source§fn dispatch_list_options(&self) -> Result<Vec<Option_>, Status>
fn dispatch_list_options(&self) -> Result<Vec<Option_>, Status>
Source§fn dispatch_list_parameters(&self) -> Result<Vec<Parameter>, Status>
fn dispatch_list_parameters(&self) -> Result<Vec<Parameter>, Status>
Source§fn dispatch_reset_options(&mut self) -> Result<(), Status>
fn dispatch_reset_options(&mut self) -> Result<(), Status>
Source§fn dispatch_reset_parameters(
&mut self,
defaults: &ServerParameters,
) -> Result<(), Status>
fn dispatch_reset_parameters( &mut self, defaults: &ServerParameters, ) -> Result<(), Status>
defaults
.