pub struct Node { /* private fields */ }Expand description
One node of one collective: its key, its store and an iroh endpoint.
Implementations§
Source§impl Node
impl Node
Sourcepub async fn bind(place: &Place, addr: SocketAddr) -> Result<Node, String>
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.
Sourcepub async fn joining(place: &Place, addr: SocketAddr) -> Result<Node, String>
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.
Sourcepub async fn open(
place: &Place,
addr: Option<SocketAddr>,
member: bool,
tweak: impl FnOnce(Builder) -> Builder,
) -> Result<Node, String>
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).
Sourcepub async fn online(&self, within: Duration) -> bool
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.
Sourcepub fn home_relay(&self) -> Option<String>
pub fn home_relay(&self) -> Option<String>
The relay this node is reachable through, once it is online.
Sourcepub fn hints(&self) -> Vec<Hint>
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.
pub fn relay(&self) -> &Relay
Sourcepub fn quiet(self) -> Node
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.
Sourcepub fn gate(&self) -> Result<(String, PathBuf), String>
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.
pub fn home(&self) -> &Path
pub fn public(&self) -> String
Sourcepub fn ticket(&self) -> String
pub fn ticket(&self) -> String
<key>@<ip:port>: what a peer passes to sync. The first of tickets.
Sourcepub fn tickets(&self) -> Vec<String>
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).
Sourcepub fn enforce(&self) -> Result<usize, String>
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.
Sourcepub fn stamp(&self) -> Result<usize, String>
pub fn stamp(&self) -> Result<usize, String>
Stamps the lines this node’s hooks wrote since the last call as its own (Store::stamp).
Sourcepub async fn sync(&self, target: &str) -> Result<Report, String>
pub async fn sync(&self, target: &str) -> Result<Report, String>
Dials the member named by target (<key>[@<hints>], addr.rs) and reconciles.
Sourcepub async fn fetch(
&self,
target: &str,
commits: &[String],
) -> Result<Report, String>
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.
Sourcepub async fn join(
&self,
ticket: &Ticket,
) -> Result<(Membership, Report), String>
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.
Sourcepub async fn incoming(&self) -> Option<Incoming>
pub async fn incoming(&self) -> Option<Incoming>
The next peer dialling in, None once the endpoint is closed.
Sourcepub async fn accept(&self) -> Result<Report, String>
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.
Sourcepub async fn handle(&self, incoming: Incoming) -> Result<Report, String>
pub async fn handle(&self, incoming: Incoming) -> Result<Report, String>
Serves one peer that dialled in.
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> 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> 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 more