Skip to main content

Node

Struct Node 

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

Implementations§

Source§

impl Node

Source

pub fn control_signal(&self) -> Arc<Notify> ⓘ

Poll at most eight queued requests, dropping expired requests. No workspace membership is implied; the peer is derived from the TLS connection. Raised once per queued control request. It carries no data; the caller still polls to learn what arrived.

Source

pub fn has_deferred_controls(&self) -> bool

True while requests set aside by poll_control_matching wait.

Source

pub fn rearm_control_signal(&self)

Wake the host for requests already queued, for example ones set aside while a membership commit was pending. Arrivals raise this themselves.

Source

pub fn poll_control(&mut self) -> Option<ControlRequest>

Source

pub fn set_inquiry_responder(&self, responder: InquiryResponder)

Answer inquiries from committed state before they reach the host queue.

Source

pub fn connection_capacity(&self) -> CapacityCounts

Connections closed to make room or refused, device-wide.

Source

pub fn control_timing(&self) -> ControlTiming

Where control requests spent their time since this node started.

Source

pub fn poll_control_matching( &mut self, matches: impl Fn(&[u8]) -> bool, ) -> Option<ControlRequest>

Find a request without consuming unrelated control traffic. Used while a membership commit is pending so admission intake can continue without reordering recovery or membership-control messages.

Source

pub fn poll_control_first( &mut self, matches: impl Fn(&[u8]) -> bool, depth: usize, ) -> Option<ControlRequest>

Take the first matching request from up to depth newly queued ones plus those already set aside; the rest keep their order. For short requests that must not wait behind a long queue (ADR 0009).

Source

pub fn control_client(&self) -> ControlClient

Source

pub fn request_control( &self, peer: PeerId, payload: &[u8], ) -> impl Future<Output = Result<Vec<u8>, Error>> + Send + 'static

Own the bounded request so a host can spawn it without borrowing its node or holding an application session lock across the network wait.

Source§

impl Node

Source

pub fn transport_metrics(&self) -> TransportMetrics

Source

pub async fn bind(address: SocketAddr) -> Result<(Self, MessageReceiver), Error>

Bind a directly reachable local address. Public discovery, relays and port mapping are disabled. Fresh identity on every bind in this version.

Source

pub async fn bind_with_identity( address: SocketAddr, secret: &[u8; 32], ) -> Result<(Self, MessageReceiver), Error>

Bind using a caller-owned, securely generated and stored 32-byte endpoint credential. This restores transport identity only, never workspace authority. The caller must prevent concurrent endpoint instances using this credential.

Source

pub async fn bind_lan( address: SocketAddr, ) -> Result<(Self, MessageReceiver), Error>

Opt in to local-network address advertisement/lookup. This publishes the endpoint key and addresses, never workspace names or membership authority. Public lookup services and relay transports remain disabled.

Source

pub async fn bind_lan_with_identity( address: SocketAddr, secret: &[u8; 32], ) -> Result<(Self, MessageReceiver), Error>

Opt in to LAN lookup while retaining a workspace-scoped endpoint identity. Advertises this endpoint key and addresses, never membership authority.

Source

pub async fn bind_nearby_with_identity( address: SocketAddr, secret: &[u8; 32], ) -> Result<(Self, MessageReceiver), Error>

Local device-level invitation discovery, isolated from workspace endpoint discovery.

Source

pub async fn bind_wan_with_identity( address: SocketAddr, secret: &[u8; 32], ) -> Result<(Self, MessageReceiver), Error>

Opt in to Iroh’s public Pkarr address lookup and relay network while retaining LAN lookup. These services provide routes, never membership.

Source

pub async fn bind_relay_with_identity( address: SocketAddr, secret: &[u8; 32], ) -> Result<(Self, MessageReceiver), Error>

Diagnostic WAN profile that forces authenticated traffic through Iroh relays while leaving the device’s Wi-Fi connection intact.

Source

pub async fn bind_wan_only_with_identity( address: SocketAddr, secret: &[u8; 32], ) -> Result<(Self, MessageReceiver), Error>

Diagnostic WAN profile that uses only public endpoint lookup and ignores LAN discovery and saved IP hints while retaining direct Iroh paths.

Source

pub async fn bind_with_profile( address: SocketAddr, secret: Option<&[u8; 32]>, profile: NetworkProfile, budget: ConnectionBudget, ) -> Result<(Self, MessageReceiver), Error>

Bind an independently identified endpoint using host-owned shared device capacity. Clone the same budget for each workspace and discovery endpoint.

Source

pub async fn bind_with_profile_and_relay( address: SocketAddr, secret: Option<&[u8; 32]>, profile: NetworkProfile, budget: ConnectionBudget, relay: RelayOptions, ) -> Result<(Self, MessageReceiver), Error>

Bind with a caller-supplied relay map and TLS trust configuration.

This is intended for controlled relay qualification and operator-managed relay deployments. The caller must select NetworkProfile::RelayOnly when direct paths must be excluded.

Source

pub fn id(&self) -> PeerId

Source

pub fn control_cancellation(&self) -> Sender<bool>

A session-local cancellation latch for outbound control exchanges.

Source

pub fn poll_membership_gossip(&self) -> Option<(WorkspaceId, Vec<u8>)>

Next membership step received by gossip, as (workspace, opaque bytes). Delivered without a policy revision check (ADR 0008): the caller must verify the step itself against its own saved state before using it.

Source

pub async fn wait_for_membership_gossip( &self, workspace: WorkspaceId, ) -> Option<Vec<u8>>

Wait for one queued membership envelope for workspace. The caller owns the deadline; no polling interval is introduced here.

Source

pub fn broadcast_membership( &self, workspace: WorkspaceId, payload: Vec<u8>, ) -> impl Future<Output = Result<bool, Error>> + Send + 'static

Broadcast a committed membership step on the workspace overlay’s reserved membership topic. Owned so the host can spawn it. Ok(false) means no overlay or no remote member to send to.

Source

pub fn address(&self) -> SocketAddr

Source

pub async fn wait_online(&self)

Wait until the endpoint has an active relay connection.

This is only needed by callers that explicitly selected a relay-only profile. It is event-driven and does not add a polling delay or fallback.

Source

pub fn resources(&self) -> ResourceTransfers

Source

pub async fn network_change(&self)

Android cannot detect host network changes from native code. The Java connectivity callback must forward them so Iroh can rebind its sockets.

Source

pub async fn add_address_hint( &self, peer: PeerId, address: SocketAddr, ) -> Result<(), Error>

Source

pub async fn remember_observed(&self, peer: PeerId, address: SocketAddr)

Remember an authenticated return path without synchronously changing any workspace gossip overlay. Control-plane observations use this narrow path so a presence reply cannot wait on peer discovery.

Source

pub async fn address_hint(&self, peer: PeerId) -> Option<SocketAddr>

A cached route is only a hint. Callers must separately authorize any workspace metadata they share with it.

Source

pub async fn nearby_peers(&self) -> Vec<PeerId>

Endpoints passively observed on the application-named local mDNS service. These are route hints only and carry no workspace or human identity claim.

Source

pub async fn nearby_workspace_peers(&self) -> Vec<PeerId>

Return a bounded batch for workspace advertisement queries.

Source

pub async fn install_verified_policy( &self, workspace: WorkspaceId, revision: u64, endpoint_permissions: BTreeMap<PeerId, Permissions>, ) -> Result<(), Error>

Trusted application seam. Never invoke with an unverified network policy. The caller resolves member/device bindings into endpoint permissions; this module neither establishes those bindings nor verifies admin authority.

Source

pub async fn enable_gossip( &self, workspace: WorkspaceId, revision: u64, ) -> Result<(), Error>

Enable one bounded workspace-wide live overlay after installing a verified policy. Direct-recipient publications keep their acknowledged path.

Source

pub async fn with_routing_policy<T>( &self, inspect: impl FnOnce(&RoutingTable) -> T, ) -> T

Read the current routing policy under the same lock used for data routing. The callback must be bounded, synchronous and must not reenter this node. Owned results may leave the lock; policy references cannot escape it.

Source

pub async fn live_neighbor_count(&self, workspace: WorkspaceId) -> usize

Current maintained live neighbors for a workspace overlay. Zero means no overlay or no connected neighbor; it is not a workspace member count.

Source

pub async fn live_neighbors(&self, workspace: WorkspaceId) -> Vec<PeerId>

Authenticated direct neighbors in the bounded workspace Gossip view. These are advisory retrieval candidates, not proof that history exists.

Source

pub async fn wait_for_gossip_neighbor(&self, workspace: WorkspaceId) -> bool

Wait for the native Gossip overlay to observe at least one neighbor. The caller owns the deadline; no polling interval is introduced here.

Source

pub async fn subscribe( &self, workspace: WorkspaceId, revision: u64, topic: Topic, ) -> Result<AdmissionReport, Error>

Source

pub async fn unsubscribe( &self, workspace: WorkspaceId, revision: u64, topic: Topic, ) -> Result<AdmissionReport, Error>

Source

pub async fn prepare_interest( &self, workspace: WorkspaceId, revision: u64, topic: Topic, subscribe: bool, ) -> Result<impl Future<Output = Result<AdmissionReport, Error>> + Send + 'static, Error>

Apply local interest before returning an owned remote announcement. Hosts may schedule this future without holding their session lock. They must serialize announcements; dropping one does not undo local interest.

Source

pub async fn publish( &self, workspace: WorkspaceId, revision: u64, topic: Topic, payload: Vec<u8>, ) -> Result<AdmissionReport, Error>

Source

pub async fn publish_with_class( &self, workspace: WorkspaceId, revision: u64, topic: Topic, delivery: DeliveryClass, payload: Vec<u8>, ) -> Result<AdmissionReport, Error>

Source

pub async fn publish_to( &self, workspace: WorkspaceId, revision: u64, topic: Topic, endpoints: Vec<PeerId>, recipients: Vec<[u8; 32]>, payload: Vec<u8>, ) -> Result<AdmissionReport, Error>

Send to authorized subscribers within the resolved audience. Each selected endpoint without announced interest gets a non-admission result.

Source

pub async fn publish_to_with_class( &self, workspace: WorkspaceId, revision: u64, topic: Topic, endpoints: Vec<PeerId>, recipients: Vec<[u8; 32]>, delivery: DeliveryClass, payload: Vec<u8>, ) -> Result<AdmissionReport, Error>

Source

pub async fn close(self)

Trait Implementations§

Source§

impl Drop for Node

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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