Skip to main content

ServerRole

Enum ServerRole 

Source
pub enum ServerRole {
    Regular,
    LogServer,
    Anchor,
}
Expand description

ServerRole describes the functional role of an NWEP server node.

The role affects how the C library routes incoming requests internally: certain path prefixes are intercepted and handled by built-in subsystems rather than dispatched to application-level handlers. A server built with the Rust bindings must choose a role at construction time via ServerBuilder::role.

The Default implementation returns ServerRole::Regular, which is the appropriate choice for application-level servers.

Variants§

§

Regular

Regular identifies a standard application server.

All incoming requests are dispatched to the application’s registered handlers. No paths are intercepted by the library. This is the default role and should be used for all nodes that do not serve trust-log or anchor functions.

§

LogServer

LogServer identifies a node that hosts the distributed Merkle identity log.

In addition to application handlers, a LogServer intercepts all requests whose path begins with /log/ and routes them to the C library’s built-in log management subsystem. These paths handle log entry submission, Merkle proof retrieval, and checkpoint synchronization.

Only designate a node as LogServer if it has been provisioned with persistent log storage and configured as a trust authority in the network’s root anchoring document.

§

Anchor

Anchor identifies a BLS threshold signing authority node.

An Anchor intercepts all requests whose path begins with /checkpoint/ and routes them to the C library’s built-in BLS checkpoint subsystem. Anchor nodes hold a BLS private key share and participate in threshold signing rounds to produce periodic checkpoints over the Merkle log root.

The network requires at least crate::types::DEFAULT_ANCHOR_THRESHOLD functioning anchor nodes to ratify a checkpoint. Anchor nodes are registered in the trust root and their BLS public keys are well-known.

Implementations§

Source§

impl ServerRole

Source

pub fn from_str(s: &str) -> Self

from_str parses a role string (as advertised in the roles header) and returns the corresponding ServerRole variant.

The parsing is delegated to the C library. Unrecognized strings map to ServerRole::Regular, which is the safe default.

§Example
use nwep::role::ServerRole;

assert_eq!(ServerRole::from_str("regular"),    ServerRole::Regular);
assert_eq!(ServerRole::from_str("log_server"), ServerRole::LogServer);
assert_eq!(ServerRole::from_str("anchor"),     ServerRole::Anchor);
assert_eq!(ServerRole::from_str("unknown"),    ServerRole::Regular);
Source

pub fn as_str(&self) -> &'static str

as_str returns the canonical lowercase wire-format string for this role.

The string is retrieved from the C library’s string table and is valid for the lifetime of the process. It is the same value that appears in the roles header of a connect response.

§Example
use nwep::role::ServerRole;

assert_eq!(ServerRole::Regular.as_str(),   "regular");
assert_eq!(ServerRole::LogServer.as_str(), "log_server");
assert_eq!(ServerRole::Anchor.as_str(),    "anchor");

Trait Implementations§

Source§

impl Clone for ServerRole

Source§

fn clone(&self) -> ServerRole

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ServerRole

Source§

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

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

impl Default for ServerRole

Source§

fn default() -> ServerRole

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

impl Display for ServerRole

Source§

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

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

impl From<u32> for ServerRole

Source§

fn from(r: c_uint) -> Self

Converts to this type from the input type.
Source§

impl Hash for ServerRole

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ServerRole

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for ServerRole

Source§

impl Eq for ServerRole

Source§

impl StructuralPartialEq for ServerRole

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.