Skip to main content

Node

Struct Node 

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

One node of one collective: its key, its store and an iroh endpoint.

Implementations§

Source§

impl Node

Source

pub async fn bind(place: &Place, addr: SocketAddr) -> Result<Node, String>

Opens the endpoint for place on addr — only after the gate, so a local collective or an off repo never even gets a socket.

Source

pub async fn joining(place: &Place, addr: SocketAddr) -> Result<Node, String>

A node of a collective whose membership this machine does not hold yet: it can only join.

Source

pub async fn open( place: &Place, addr: Option<SocketAddr>, member: bool, tweak: impl FnOnce(Builder) -> Builder, ) -> Result<Node, String>

The endpoint for the collective’s relay setting (addr.rs). addr is the UDP socket for direct paths (None: relay only, for tests); member: refuse without a membership; tweak adjusts the builder (tests trust a local relay’s self-signed certificate).

Source

pub async fn online(&self, within: Duration) -> bool

Waits until the endpoint holds a connection to its home relay (at most within); true if it does. Nothing to wait for with relays disabled.

Source

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

The relay this node is reachable through, once it is online.

Source

pub fn hints(&self) -> Vec<Hint>

Where another machine could reach this node: its direct addresses (tickets) and its home relay. What serve writes to mesh/addr.json for invite to put in a ticket.

Source

pub fn relay(&self) -> &Relay

Source

pub fn quiet(self) -> Node

A node that only dials and exits (sync, fetch): it tells no peer where it listens, because its ephemeral port is gone a moment later.

Source

pub fn gate(&self) -> Result<(String, PathBuf), String>

The gate again, on the config as it is now, and the store must still be the bound one.

Source

pub fn home(&self) -> &Path

Source

pub fn public(&self) -> String

Source

pub fn ticket(&self) -> String

<key>@<ip:port>: what a peer passes to sync. The first of tickets.

Source

pub fn tickets(&self) -> Vec<String>

One ticket per address another machine could dial. Bound to a specific IP that is the one; bound to an unspecified IP (0.0.0.0, the default) it is each interface address iroh found, never 0.0.0.0 itself (empty if there is none: then --bind IP:PORT).

Source

pub fn enforce(&self) -> Result<usize, String>

Applies the held membership to the logs unless they were already checked against it (a join or revoke by another process, or a sync, changed it). Returns how many lines moved.

Source

pub fn stamp(&self) -> Result<usize, String>

Stamps the lines this node’s hooks wrote since the last call as its own (Store::stamp).

Source

pub async fn sync(&self, target: &str) -> Result<Report, String>

Dials the member named by target (<key>[@<hints>], addr.rs) and reconciles.

Source

pub async fn fetch( &self, target: &str, commits: &[String], ) -> Result<Report, String>

sync, also asking the peer for the reasoning excerpts of commits (step 5): what it holds lands in this node’s reasoning.jsonl.

Source

pub async fn join( &self, ticket: &Ticket, ) -> Result<(Membership, Report), String>

Joins with an invite ticket (invite.rs): dials the admin that issued it, presents the signed invite, installs the membership history it answers with (trusted because iroh authenticated the ticket’s admin key), remembers the admin as a peer and syncs with it at once.

Source

pub async fn incoming(&self) -> Option<Incoming>

The next peer dialling in, None once the endpoint is closed.

Source

pub async fn accept(&self) -> Result<Report, String>

Serves the next peer that dials in; returns what it moved, or why it was turned away.

Source

pub async fn handle(&self, incoming: Incoming) -> Result<Report, String>

Serves one peer that dialled in.

Source

pub async fn close(&self)

Auto Trait Implementations§

§

impl !Freeze for Node

§

impl !RefUnwindSafe for Node

§

impl !UnwindSafe 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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