Skip to main content

NodeStore

Struct NodeStore 

Source
pub struct NodeStore { /* private fields */ }

Implementations§

Source§

impl NodeStore

Source

pub fn open(path: &Path) -> Result<Self, String>

Opens the registry, empty when the file does not exist. A file that exists and does not parse is an error, not an empty registry: silently forgetting every enrolled node would re-open every enrollment token.

Source

pub fn mint_token( &mut self, name: &str, projects: Vec<String>, ttl_secs: i64, now_secs: i64, ) -> Result<(String, i64), String>

Mints a single-use enrollment token. Returns the plaintext once.

Source

pub fn enroll( &mut self, token: &str, pubkey_hex: &str, listen: Option<ListenInfo>, now_secs: i64, now_iso: &str, ) -> Result<NodeRecord, String>

Spends a token and registers the node’s public key.

Source

pub fn authenticate( &mut self, node_id: &str, method: &str, path: &str, ts_ms: i64, body: &[u8], sig_hex: &str, now_ms: i64, ) -> Result<NodeRecord, AuthError>

Checks a signed request and, on success, advances the node’s replay mark.

Source

pub fn hub_node_key(&mut self) -> Result<(String, String), String>

The hub’s transport key for listening nodes as (seed, public), made on first use.

Source

pub fn listening(&self) -> Vec<NodeRecord>

Active nodes the hub has to dial.

Source

pub fn mark_polled(&mut self, id: &str, now_iso: &str)

Notes that the hub polled id just now.

Source

pub fn list(&self) -> Vec<NodeRecord>

Source

pub fn get(&self, id: &str) -> Option<NodeRecord>

Source

pub fn find(&self, name_or_id: &str) -> Option<NodeRecord>

Finds an active node by name or id.

Source

pub fn revoke(&mut self, id: &str, now_iso: &str) -> Result<NodeRecord, String>

Source

pub fn record_beat( &mut self, id: &str, beat: &Beat, desired: &dyn Fn(&TargetReport) -> Result<String, String>, now_iso: &str, ) -> Result<(), String>

Replaces a node’s observed state from a beat. desired is what the hub would write for each target id (Ok(sha)), or why it will not (Err).

Source

pub fn accept(&mut self, id: &str, target: &str) -> Result<String, String>

Records the hash a human accepted into the vault for a pull target.

Source§

impl NodeStore

Source

pub fn set_approval_policy( &mut self, id: &str, policy: &str, ) -> Result<NodeRecord, String>

Sets whether every push to a node is held for a human.

Source

pub fn usable_approval( &self, node_id: &str, target: &str, sha: &str, now_secs: i64, ) -> Option<ApprovalRecord>

The approval for exactly these bytes, if there is one and it can still be used: approved, within its lifetime, for an active node.

Source

pub fn approval_for( &self, node_id: &str, target: &str, sha: &str, ) -> Option<ApprovalRecord>

The newest request for these bytes in any state.

Source

pub fn request_approval( &mut self, node_id: &str, target: &TargetReport, sha: &str, from_seq: Option<i64>, to_seq: Option<i64>, now_secs: i64, now_iso: &str, ) -> Result<ApprovalRecord, String>

Opens a request for a human, unless one for the same bytes is already open, decided, or spent. A consumed or expired request for the same bytes (a revert) opens a fresh one: an old yes does not cover a later push.

Source

pub fn decide( &mut self, approval_id: &str, approve: bool, by: &str, now_secs: i64, now_iso: &str, ) -> Result<ApprovalRecord, String>

A human’s answer. Only a pending request can be decided: an approval is never revived, and a decision on stale bytes is a decision on a request the hub no longer asks for.

Source

pub fn add_approver( &mut self, pubkey_hex: &str, label: &str, now_iso: &str, ) -> Result<Approver, String>

Registers a device whose signature counts as the owner’s approval.

Source

pub fn remove_approver(&mut self, fp_prefix: &str) -> Result<Approver, String>

Removes a device by (a prefix of at least 8 characters of) its fingerprint. Nodes set to device approval lose their only approver if this was the last one: they fall back to required, so nothing is left unapprovable and nothing silently becomes approvable by the hub alone.

Source

pub fn approvers(&self) -> Vec<Approver>

Source

pub fn decide_signed( &mut self, approval_id: &str, signed: SignedApproval, now_secs: i64, now_iso: &str, ) -> Result<ApprovalRecord, String>

A human’s yes, signed on their own device. The hub holds no key that could have made it: it checks the signature against the registered devices, that the token names exactly this request (node, target, bytes, request id), and that its lifetime is no longer than the hub’s own.

Source

pub fn approvals(&self, node_id: Option<&str>) -> Vec<ApprovalRecord>

Requests, newest first; for one node or all.

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more