Skip to main content

Link

Struct Link 

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

A handshaked link to one station. Cloning it shares the link.

Implementations§

Source

pub async fn call(&self, c: Call) -> Result<Value, LinkError>

Signs c as a CALL, sends it, and waits for the RESULT or ERROR that verifies for it.

Source

pub async fn put_record(&self, wire: &[u8]) -> Result<(), LinkError>

Stores a signed record, as its wire bytes, in the station’s DHT.

Source

pub async fn find_record(&self, key: &[u8; 32]) -> Result<Verified, LinkError>

The record stored under key, verified.

Source

pub async fn find_records( &self, key: &[u8; 32], ) -> Result<(Vec<Verified>, usize), LinkError>

Every record stored under key that verifies, and how many the station returned that did not.

Source

pub async fn find_records_by_type( &self, t: RecordType, ) -> Result<(Vec<Verified>, usize), LinkError>

Every record of type t the station holds that verifies, and how many it returned that did not.

Source

pub async fn publish(&self, p: Publication) -> Result<(), LinkError>

Signs p as a PUBLISH and sends it.

Source

pub async fn publish_signed( &self, p: &SignedPublication, ) -> Result<(), LinkError>

Sends a publication signed once for several links, as it is.

Source

pub async fn subscribe( &self, realm: &[u8; 32], topic: &str, ) -> Result<Subscription, LinkError>

Subscribes to topic in realm: the first subscription to a realm and topic on the link sends SUBSCRIBE.

Source

pub async fn serve(&self, o: Offer) -> Result<Served, LinkError>

Advertises o’s procedure on the link and answers its CALLs until stopped. For an org procedure it resolves the org directory and this node’s procedure delegation from the DHT; a procedure in this node’s own namespace needs neither, and another node’s namespace is refused. It signs the advertisement with this node’s identity key, naming the connected station as the serving station and living no longer than the records it carries nor 5 minutes, and checks its authorization (against the realm key for an org procedure) before sending it in an ADVERTISE and putting it in the DHT. The advertisement is renewed at half its lifetime.

Source

pub async fn open_stream(&self, c: StreamCall) -> Result<Stream, LinkError>

Opens a streaming session: a QUIC stream of its own, on which it writes the signed STREAM_OPEN. A stream it opens but cannot write the open on is released before the error returns.

Source

pub async fn dial(cfg: Config) -> Result<Link, LinkError>

Dials cfg.target, runs the v4 handshake as a client, and returns the link once the station’s HELLO accepts it, within HANDSHAKE_TIMEOUT.

Source

pub fn station_node_id(&self) -> [u8; 32]

The node_id of the station the link reached.

Source

pub fn serial(&self) -> u64

A number distinct for every link this process dials.

Source

pub fn node_id(&self) -> [u8; 32]

The node_id this link connected as.

Source

pub fn station_capabilities(&self) -> u64

The capability bits the station’s HELLO announced.

Source

pub fn profile(&self) -> Profile

The profile the link runs.

Source

pub fn error(&self) -> Option<LinkError>

Why the link ended, or None while it runs.

Source

pub async fn done(&self) -> LinkError

Waits until the link has ended, and says why.

Source

pub fn unrouted(&self) -> HashMap<String, u64>

The frames received that nothing on this link handles, by what they were.

Source

pub async fn close(&self, reason: &str) -> Result<(), LinkError>

Sends a GOODBYE with reason, closes the control stream’s sending side, waits up to a second for the station to close the connection, and ends the link. Closing an ended link does nothing.

Trait Implementations§

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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