Struct spirit_tokio::UdpListen [−][src]
A configuration fragment describing a bound UDP socket.
This is similar to TcpListen
, but for UDP sockets. While the action
on a TCP socket is called for each new accepted connection, the action for UDP socket is used
to handle the whole UDP socket created from this configuration.
Type parameters
ExtraCfg
: Extra options folded into this configuration, for application specific options. They are passed to the action.ScaleMode
: How scaling should be done. If scaling is enabled, the action should handle situation where it runs in multiple instances. However, even in case scaling is disabled, the action needs to handle being „restarted“ ‒ if there's a new configuration for the socket, the old future is dropped and new one, with a new socket, is created.
Configuration options
In addition to options provided by the above type parameters, these are present:
host
: The hostname/interface to bind to. Defaults to*
.port
: The port to bind the UDP socket to (mandatory). While it is possible to create unbound UDP sockets with an OS-assigned port, these don't need the configuration and are not created by this configuration fragment.
Methods
impl<ExtraCfg, ScaleMode> UdpListen<ExtraCfg, ScaleMode> where
ExtraCfg: Clone + Debug + PartialEq + Send + 'static,
ScaleMode: Scaled,
[src]
impl<ExtraCfg, ScaleMode> UdpListen<ExtraCfg, ScaleMode> where
ExtraCfg: Clone + Debug + PartialEq + Send + 'static,
ScaleMode: Scaled,
pub fn helper<Extract, ExtractIt, Action, Fut, Name, S, O, C>(
extract: Extract,
action: Action,
name: Name
) -> impl Helper<S, O, C> where
S: Borrow<ArcSwap<C>> + Sync + Send + 'static,
C: Deserialize<'de> + Send + Sync + 'static,
O: Debug + StructOpt + Sync + Send + 'static,
Extract: FnMut(&C) -> ExtractIt + Send + 'static,
ExtractIt: IntoIterator<Item = Self>,
Action: Fn(&Arc<Spirit<S, O, C>>, UdpSocket, &ExtraCfg) -> Fut + Sync + Send + 'static,
Fut: Future<Item = (), Error = Error> + Send + 'static,
Name: Clone + Display + Send + Sync + 'static,
[src]
pub fn helper<Extract, ExtractIt, Action, Fut, Name, S, O, C>(
extract: Extract,
action: Action,
name: Name
) -> impl Helper<S, O, C> where
S: Borrow<ArcSwap<C>> + Sync + Send + 'static,
C: Deserialize<'de> + Send + Sync + 'static,
O: Debug + StructOpt + Sync + Send + 'static,
Extract: FnMut(&C) -> ExtractIt + Send + 'static,
ExtractIt: IntoIterator<Item = Self>,
Action: Fn(&Arc<Spirit<S, O, C>>, UdpSocket, &ExtraCfg) -> Fut + Sync + Send + 'static,
Fut: Future<Item = (), Error = Error> + Send + 'static,
Name: Clone + Display + Send + Sync + 'static,
Returns a helper for handling reconfiguration of the UDP sockets.
While it can be used manually, it is usually used through the
spirit::Builder::config_helper
with extractor returning an iterator of UdpListen
.
Trait Implementations
impl<ExtraCfg: Clone, ScaleMode: Clone + Scaled> Clone for UdpListen<ExtraCfg, ScaleMode>
[src]
impl<ExtraCfg: Clone, ScaleMode: Clone + Scaled> Clone for UdpListen<ExtraCfg, ScaleMode>
fn clone(&self) -> UdpListen<ExtraCfg, ScaleMode>
[src]
fn clone(&self) -> UdpListen<ExtraCfg, ScaleMode>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<ExtraCfg: Debug, ScaleMode: Debug + Scaled> Debug for UdpListen<ExtraCfg, ScaleMode>
[src]
impl<ExtraCfg: Debug, ScaleMode: Debug + Scaled> Debug for UdpListen<ExtraCfg, ScaleMode>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<ExtraCfg: Default, ScaleMode: Default + Scaled> Default for UdpListen<ExtraCfg, ScaleMode>
[src]
impl<ExtraCfg: Default, ScaleMode: Default + Scaled> Default for UdpListen<ExtraCfg, ScaleMode>
fn default() -> UdpListen<ExtraCfg, ScaleMode>
[src]
fn default() -> UdpListen<ExtraCfg, ScaleMode>
Returns the "default value" for a type. Read more
impl<ExtraCfg: Eq, ScaleMode: Eq + Scaled> Eq for UdpListen<ExtraCfg, ScaleMode>
[src]
impl<ExtraCfg: Eq, ScaleMode: Eq + Scaled> Eq for UdpListen<ExtraCfg, ScaleMode>
impl<ExtraCfg: PartialEq, ScaleMode: PartialEq + Scaled> PartialEq for UdpListen<ExtraCfg, ScaleMode>
[src]
impl<ExtraCfg: PartialEq, ScaleMode: PartialEq + Scaled> PartialEq for UdpListen<ExtraCfg, ScaleMode>
fn eq(&self, other: &UdpListen<ExtraCfg, ScaleMode>) -> bool
[src]
fn eq(&self, other: &UdpListen<ExtraCfg, ScaleMode>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &UdpListen<ExtraCfg, ScaleMode>) -> bool
[src]
fn ne(&self, other: &UdpListen<ExtraCfg, ScaleMode>) -> bool
This method tests for !=
.
impl<ExtraCfg: Ord, ScaleMode: Ord + Scaled> Ord for UdpListen<ExtraCfg, ScaleMode>
[src]
impl<ExtraCfg: Ord, ScaleMode: Ord + Scaled> Ord for UdpListen<ExtraCfg, ScaleMode>
fn cmp(&self, other: &UdpListen<ExtraCfg, ScaleMode>) -> Ordering
[src]
fn cmp(&self, other: &UdpListen<ExtraCfg, ScaleMode>) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<ExtraCfg: PartialOrd, ScaleMode: PartialOrd + Scaled> PartialOrd for UdpListen<ExtraCfg, ScaleMode>
[src]
impl<ExtraCfg: PartialOrd, ScaleMode: PartialOrd + Scaled> PartialOrd for UdpListen<ExtraCfg, ScaleMode>
fn partial_cmp(
&self,
other: &UdpListen<ExtraCfg, ScaleMode>
) -> Option<Ordering>
[src]
fn partial_cmp(
&self,
other: &UdpListen<ExtraCfg, ScaleMode>
) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &UdpListen<ExtraCfg, ScaleMode>) -> bool
[src]
fn lt(&self, other: &UdpListen<ExtraCfg, ScaleMode>) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &UdpListen<ExtraCfg, ScaleMode>) -> bool
[src]
fn le(&self, other: &UdpListen<ExtraCfg, ScaleMode>) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &UdpListen<ExtraCfg, ScaleMode>) -> bool
[src]
fn gt(&self, other: &UdpListen<ExtraCfg, ScaleMode>) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &UdpListen<ExtraCfg, ScaleMode>) -> bool
[src]
fn ge(&self, other: &UdpListen<ExtraCfg, ScaleMode>) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<ExtraCfg: Hash, ScaleMode: Hash + Scaled> Hash for UdpListen<ExtraCfg, ScaleMode>
[src]
impl<ExtraCfg: Hash, ScaleMode: Hash + Scaled> Hash for UdpListen<ExtraCfg, ScaleMode>
fn hash<__HExtraCfgScaleMode: Hasher>(&self, state: &mut __HExtraCfgScaleMode)
[src]
fn hash<__HExtraCfgScaleMode: Hasher>(&self, state: &mut __HExtraCfgScaleMode)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<S, O, C, Action, Fut, ExtraCfg, ScaleMode> IteratedCfgHelper<S, O, C, Action> for UdpListen<ExtraCfg, ScaleMode> where
S: Borrow<ArcSwap<C>> + Sync + Send + 'static,
C: Deserialize<'de> + Send + Sync + 'static,
O: Debug + StructOpt + Sync + Send + 'static,
ExtraCfg: Clone + Debug + PartialEq + Send + 'static,
Action: Fn(&Arc<Spirit<S, O, C>>, UdpSocket, &ExtraCfg) -> Fut + Sync + Send + 'static,
Fut: Future<Item = (), Error = Error> + Send + 'static,
ScaleMode: Scaled,
[src]
impl<S, O, C, Action, Fut, ExtraCfg, ScaleMode> IteratedCfgHelper<S, O, C, Action> for UdpListen<ExtraCfg, ScaleMode> where
S: Borrow<ArcSwap<C>> + Sync + Send + 'static,
C: Deserialize<'de> + Send + Sync + 'static,
O: Debug + StructOpt + Sync + Send + 'static,
ExtraCfg: Clone + Debug + PartialEq + Send + 'static,
Action: Fn(&Arc<Spirit<S, O, C>>, UdpSocket, &ExtraCfg) -> Fut + Sync + Send + 'static,
Fut: Future<Item = (), Error = Error> + Send + 'static,
ScaleMode: Scaled,
fn apply<Extractor, ExtractedIter, Name>(
extractor: Extractor,
action: Action,
name: Name,
builder: Builder<S, O, C>
) -> Builder<S, O, C> where
Extractor: FnMut(&C) -> ExtractedIter + Send + 'static,
ExtractedIter: IntoIterator<Item = Self>,
Name: Clone + Display + Send + Sync + 'static,
[src]
fn apply<Extractor, ExtractedIter, Name>(
extractor: Extractor,
action: Action,
name: Name,
builder: Builder<S, O, C>
) -> Builder<S, O, C> where
Extractor: FnMut(&C) -> ExtractedIter + Send + 'static,
ExtractedIter: IntoIterator<Item = Self>,
Name: Clone + Display + Send + Sync + 'static,
Perform the transformation of the builder. Read more
impl<S, O, C, Action, Fut, ExtraCfg, ScaleMode> CfgHelper<S, O, C, Action> for UdpListen<ExtraCfg, ScaleMode> where
S: Borrow<ArcSwap<C>> + Sync + Send + 'static,
C: Deserialize<'de> + Send + Sync + 'static,
O: Debug + StructOpt + Sync + Send + 'static,
ExtraCfg: Clone + Debug + PartialEq + Send + 'static,
Action: Fn(&Arc<Spirit<S, O, C>>, UdpSocket, &ExtraCfg) -> Fut + Sync + Send + 'static,
Fut: Future<Item = (), Error = Error> + Send + 'static,
ScaleMode: Scaled,
[src]
impl<S, O, C, Action, Fut, ExtraCfg, ScaleMode> CfgHelper<S, O, C, Action> for UdpListen<ExtraCfg, ScaleMode> where
S: Borrow<ArcSwap<C>> + Sync + Send + 'static,
C: Deserialize<'de> + Send + Sync + 'static,
O: Debug + StructOpt + Sync + Send + 'static,
ExtraCfg: Clone + Debug + PartialEq + Send + 'static,
Action: Fn(&Arc<Spirit<S, O, C>>, UdpSocket, &ExtraCfg) -> Fut + Sync + Send + 'static,
Fut: Future<Item = (), Error = Error> + Send + 'static,
ScaleMode: Scaled,