Struct agde::Capabilities
source · pub struct Capabilities { /* private fields */ }
Expand description
Describes the capabilities and properties of the client. Sent in the initial Message
exchange.
Implementations§
source§impl Capabilities
impl Capabilities
sourcepub fn new(uuid: Uuid, persistent: bool, help_desire: i16) -> Self
pub fn new(uuid: Uuid, persistent: bool, help_desire: i16) -> Self
Creates a new set of capabilities and properties used by this client.
See the various getters for more information about the usage of these options.
sourcepub fn version_compatible(&self, other: &Capabilities) -> bool
pub fn version_compatible(&self, other: &Capabilities) -> bool
Check is the versions are compatible.
sourcepub fn persistent(&self) -> bool
pub fn persistent(&self) -> bool
The client is striving to be persistent. These will regularly do MessageKind::HashCheck
.
sourcepub fn help_desire(&self) -> i16
pub fn help_desire(&self) -> i16
The desire to communicate with others in the system.
This value will go from i16::MIN
, which means “I want none o’ this” to
i16::MAX
which means the client is happy to help others.
See Self::effective_help_desire
for how this range is used.
This will usually be set in accordance to the free processing power a client has to offer.
This will play part in deciding which client to send check requests to. Normally, the always-on clients (those started alongside the server, if there is any), will have a high value.
sourcepub fn effective_help_desire(&self) -> f32
pub fn effective_help_desire(&self) -> f32
Returns a desire to help in a lower range.
This can be used to calculate the relative desire.
For now, the whole i16
range is collapsed to [0..9)
This uses a root function (⁵√self.help_desire
).
This leads to a help_desire
of 1024
being just
half as likely to be chosen as i16::MAX
.
A help_desire
of 0
returns 1
from this function.
The value returned from this function will never be 0
or less.
Trait Implementations§
source§impl Clone for Capabilities
impl Clone for Capabilities
source§fn clone(&self) -> Capabilities
fn clone(&self) -> Capabilities
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Capabilities
impl Debug for Capabilities
source§impl<'de> Deserialize<'de> for Capabilities
impl<'de> Deserialize<'de> for Capabilities
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl PartialEq<Capabilities> for Capabilities
impl PartialEq<Capabilities> for Capabilities
source§fn eq(&self, other: &Capabilities) -> bool
fn eq(&self, other: &Capabilities) -> bool
self
and other
values to be equal, and is used
by ==
.