Skip to main content

Node

Struct Node 

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

Implementations§

Source§

impl Node

Source

pub async fn start( dir: &Path, connector: &Connector, ) -> Result<(Self, Receiver<Message>)>

Starts this computer’s node. State (its key and the roster) lives in dir. Messages for agents the app delivers to (Reach::App) come out of the returned inbox.

Source

pub fn id(&self) -> EndpointId

Source

pub fn name(&self) -> Option<String>

This computer’s name, once it is in a network.

Source

pub fn network_id(&self) -> Option<String>

The network’s id (its root key), once this computer is in one.

Source

pub fn role(&self) -> Option<Role>

Source

pub fn create(&self, name: &str) -> Result<String>

Starts a new network with this computer as its owner. Returns the recovery code: show it once; it is kept nowhere.

Source

pub fn invite(&self) -> Result<String>

A one-time invite for another computer, good for an hour while this one stays on.

Source

pub async fn join(&self, ticket: &str, name: &str) -> Result<()>

Source

pub fn remove(&self, computer: &str, cascade: bool) -> Result<()>

Takes a computer out of the network for good. cascade also voids every computer it admitted: for one that was stolen.

Source

pub fn promote(&self, computer: &str) -> Result<()>

The owner makes a computer an admin: it can invite and remove members.

Source

pub fn recover(&self, code: &str) -> Result<()>

Makes this computer the owner with the network’s recovery code, for when the owner was lost. Remove the old one afterwards.

Source

pub fn set_agents(&self, agents: impl IntoIterator<Item = (Agent, Reach)>)

What this computer offers. The first call opens it to letters, and the others hear at once (the hello that catches up with them, which a computer that was off may need for a removal it missed), so what waited for it while it started comes now.

Source

pub fn set_senders(&self, senders: impl IntoIterator<Item = String>)

Names the app sends letters as without offering them to the network: a hosted assistant that asks agents elsewhere but can’t be asked itself. Answers to its letters still come back.

Source

pub fn set_rules(&self, rules: Vec<Rule>) -> Result<()>

Who on the other computers may write to this computer’s agents, the first match deciding. Answers to this computer’s own letters always pass, so a rule added while a request runs doesn’t strand it.

Source

pub fn rules(&self) -> Vec<Rule>

Source

pub fn set_network_name(&self, name: Option<String>)

What the app calls this network (home, work) when a computer is in several: the invites it makes carry the name, so the computer that joins can call it the same (crate::read_invite).

Source

pub fn set_reply_command(&self, command: impl Into<String>)

The command agents the network knocks on run to reply (default codync-network).

Source

pub async fn peers(&self) -> Result<Vec<Peer>>

Every computer in the network, asked now for what it offers.

Source

pub fn directory(&self) -> Vec<Peer>

Every computer in the network, as last heard, without asking anyone.

Source

pub fn changes(&self) -> Receiver<()>

Changes whenever what Node::directory shows does: a computer joins or leaves, a role or name changes, another computer offers different agents, or it starts or stops answering. Ticks only; read the directory for what changed.

Source

pub fn resolve(&self, name: &str) -> Result<Address>

Where a bare agent name or a full agent@computer points: this computer first, then the directory. Refuses a name more than one computer has, naming them.

Source

pub async fn send(&self, letter: Letter) -> Result<Sent>

Sends a letter from one of the agents this computer offers. An answer (reply_to) may also come from one it no longer offers: renamed or gone while it worked, it still says how it ended.

Source

pub async fn shutdown(&self)

Stops answering and closes the endpoint (leaving a network, or quitting).

Auto Trait Implementations§

§

impl !RefUnwindSafe for Node

§

impl !UnwindSafe for Node

§

impl Forget for Node

§

impl Freeze for Node

§

impl Move for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

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

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