Skip to main content

NodeCapabilities

Struct NodeCapabilities 

Source
pub struct NodeCapabilities(/* private fields */);
Expand description

Capability flags for Peat nodes.

These flags are announced during handshake so peers know what features each node supports.

Implementations§

Source§

impl NodeCapabilities

Source

pub const PERSISTENT_STORAGE: u16 = 0x0001

Can persist data across restarts.

Source

pub const RELAY_CAPABLE: u16 = 0x0002

Can forward messages for multi-hop routing.

Source

pub const DOCUMENT_CRDT: u16 = 0x0004

Supports full Automerge documents.

Source

pub const PRIMITIVE_CRDT: u16 = 0x0008

Supports primitive CRDTs (LWW, counters, sets).

Source

pub const BLOB_STORAGE: u16 = 0x0010

Can store and serve blobs.

Source

pub const HISTORY_QUERY: u16 = 0x0020

Can answer historical queries.

Source

pub const AGGREGATION: u16 = 0x0040

Can aggregate data for upstream.

Source

pub const SENSOR_INPUT: u16 = 0x0080

Has sensor inputs.

Source

pub const DISPLAY_OUTPUT: u16 = 0x0100

Has display output.

Source

pub const ACTUATION: u16 = 0x0200

Has actuation capability (motors, etc.).

Source

pub const fn empty() -> Self

Create empty capabilities.

Source

pub const fn all() -> Self

Create capabilities with all flags set.

Source

pub const fn lite() -> Self

Create typical Peat-Lite capabilities.

Source

pub const fn full() -> Self

Create typical Peat-Full capabilities.

Source

pub const fn from_bits(bits: u16) -> Self

Create new capabilities from raw bits.

Source

pub const fn bits(&self) -> u16

Get raw bits.

Source

pub const fn has(&self, cap: u16) -> bool

Check if a capability is set.

Source

pub fn set(&mut self, cap: u16)

Set a capability.

Source

pub fn clear(&mut self, cap: u16)

Clear a capability.

Source

pub const fn intersection(&self, other: &Self) -> Self

Get intersection of capabilities (what both nodes support).

Source

pub const fn can_sync_with(&self, other: &Self) -> bool

Check if this node can sync CRDTs with another.

Source

pub fn encode(&self) -> [u8; 2]

Encode to 2 bytes (little-endian).

Source

pub fn decode(bytes: [u8; 2]) -> Self

Decode from 2 bytes (little-endian).

Trait Implementations§

Source§

impl Clone for NodeCapabilities

Source§

fn clone(&self) -> NodeCapabilities

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for NodeCapabilities

Source§

impl Debug for NodeCapabilities

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NodeCapabilities

Source§

fn default() -> NodeCapabilities

Returns the “default value” for a type. Read more
Source§

impl Display for NodeCapabilities

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for NodeCapabilities

Source§

impl PartialEq for NodeCapabilities

Source§

fn eq(&self, other: &NodeCapabilities) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for NodeCapabilities

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.