Struct ServerBuilder

Source
pub struct ServerBuilder { /* private fields */ }
Available on crate feature server only.
Expand description

The server builder.

Convenient builder to help building a final Server.

Implementations§

Source§

impl ServerBuilder

Source

pub fn new() -> Self

Create a new server builder using defaults.

Source

pub fn with_server_config(self, config: ServerConfig) -> Self

Set the server configuration.

Source

pub fn with_timer_config(self, config: TimerConfig) -> Self

Set the timer configuration.

Source

pub fn with_pomodoro_config(self) -> Self

Configure the timer to follow the Pomodoro time management method, which alternates 25 min of work and 5 min of breaks 4 times, then ends with a long break of 15 min.

See https://en.wikipedia.org/wiki/Pomodoro_Technique.

Source

pub fn with_52_17_config(self) -> Self

Configure the timer to follow the 52/17 time management method, which alternates 52 min of work and 17 min of resting.

See https://en.wikipedia.org/wiki/52/17_rule.

Source

pub fn with_server_handler<F: Future<Output = Result<()>> + Send + 'static>( self, handler: impl Fn(ServerEvent) -> F + Send + Sync + 'static, ) -> Self

Set the server handler.

Source

pub fn with_binder(self, binder: Box<dyn ServerBind>) -> Self

Push the given server binder.

Source

pub fn with_timer_handler<F: Future<Output = Result<()>> + Send + 'static>( self, handler: impl Fn(TimerEvent) -> F + Sync + Send + 'static, ) -> Self

Set the timer handler.

Source

pub fn with_cycle<C>(self, cycle: C) -> Self
where C: Into<TimerCycle>,

Push the given timer cycle.

Source

pub fn with_cycles<C, I>(self, cycles: I) -> Self
where C: Into<TimerCycle>, I: IntoIterator<Item = C>,

Set the timer cycles.

Source

pub fn with_cycles_count(self, count: impl Into<TimerLoop>) -> Self

Set the timer cycles count.

Source

pub fn build(self) -> Result<Server>

Build the final server.

Trait Implementations§

Source§

impl Default for ServerBuilder

Source§

fn default() -> ServerBuilder

Returns the “default value” for a type. 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.