pub struct NodeIdentity {
pub cluster_id: ClusterId,
pub node_id: NodeId,
pub created_at: HlcTimestamp,
pub format_version: u32,
}Expand description
Persisted node identity (spec section 11.1, S2A-001).
Serialized as versioned JSON; format_version is part of the struct per
S2A-001 and is verified on every load. Unknown fields and unknown versions
fail closed (spec section 4.10).
Fields§
§cluster_id: ClusterIdCluster this node is bound to for the lifetime of its data directory.
node_id: NodeIdThis node’s identifier within the cluster.
created_at: HlcTimestampWall-clock time the identity was minted (informational).
format_version: u32Durable format version; see NODE_IDENTITY_FORMAT_VERSION.
Implementations§
Source§impl NodeIdentity
impl NodeIdentity
Sourcepub fn load(node_data: &Path) -> Result<Option<Self>, ClusterError>
pub fn load(node_data: &Path) -> Result<Option<Self>, ClusterError>
Load and verify the persisted identity, if present.
Returns Ok(None) when no identity has been minted yet. A present but
undecodable, unknown-version, or reserved-identifier file fails closed
with a typed error; it is never silently replaced.
Sourcepub fn load_or_create(
node_data: &Path,
csprng: Csprng<'_>,
) -> Result<Self, ClusterError>
pub fn load_or_create( node_data: &Path, csprng: Csprng<'_>, ) -> Result<Self, ClusterError>
Load the persisted identity, or mint and persist a fresh one on first
boot (cluster_id and node_id drawn from csprng).
Concurrent first boots on one directory race on an atomic create-if-absent publish; the loser loads and returns the winner’s identity, so the result is stable.
Trait Implementations§
Source§impl Clone for NodeIdentity
impl Clone for NodeIdentity
Source§fn clone(&self) -> NodeIdentity
fn clone(&self) -> NodeIdentity
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NodeIdentity
impl Debug for NodeIdentity
Source§impl<'de> Deserialize<'de> for NodeIdentity
impl<'de> Deserialize<'de> for NodeIdentity
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>,
impl Eq for NodeIdentity
Source§impl PartialEq for NodeIdentity
impl PartialEq for NodeIdentity
Source§impl Serialize for NodeIdentity
impl Serialize for NodeIdentity
impl StructuralPartialEq for NodeIdentity
Auto Trait Implementations§
impl Freeze for NodeIdentity
impl RefUnwindSafe for NodeIdentity
impl Send for NodeIdentity
impl Sync for NodeIdentity
impl Unpin for NodeIdentity
impl UnsafeUnpin for NodeIdentity
impl UnwindSafe for NodeIdentity
Blanket Implementations§
impl<T> AppData for Twhere
T: OptionalSend + OptionalSync + 'static + OptionalSerde,
impl<T> AppDataResponse for Twhere
T: OptionalSend + OptionalSync + 'static + OptionalSerde,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request