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
impl ServerRole
Sourcepub fn from_str(s: &str) -> Self
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);Sourcepub fn as_str(&self) -> &'static str
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
impl Clone for ServerRole
Source§fn clone(&self) -> ServerRole
fn clone(&self) -> ServerRole
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more