Skip to main content

Pool

Struct Pool 

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

A node’s station links. Cloning it shares the pool; the pool closes when Pool::close is called or its last handle is dropped.

Implementations§

Source§

impl Pool

Source

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

Calls a procedure at a provider that serves it, as macula 12 calls one. A provider’s ERROR comes back as PoolError::Link(LinkError::Provider { .. }); when no candidate answers, PoolError::NoProvider names each one tried.

Source

pub async fn providers( &self, realm: &[u8; 32], procedure: &str, ) -> Result<Vec<Provider>, PoolError>

Every provider whose advertisement of procedure in realm the realm’s pinned key authorizes, with the station each serves from, freshest first.

Source

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

Opens a streaming session at a provider of the procedure, reached as Pool::call reaches one. The stream is open once its STREAM_OPEN is sent; a provider’s or station’s refusal arrives on its first recv.

Source

pub async fn station_target( &self, station: &[u8; 32], ) -> Result<Target, PoolError>

Where station is dialed, from the station_endpoint record the station signed itself; one another key signed is refused.

A link to station: one the pool holds, or a direct link it dials to the address in the station’s own endpoint record, pinned by its node_id, within the default call timeout. A direct link that does not come up on its first dial is not kept.

Source

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

The record under key, verified, from the first link that answers.

Source

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

The records under key that verify, and how many did not, from the first link that answers.

Source

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

The records of type t that verify, and how many did not, from the first link that answers.

Source

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

Puts a signed record through the first link whose station takes it.

Source§

impl Pool

Source

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

Subscribes the node to topic in realm on every link.

Source

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

Signs p once and sends it on the first replication_factor links, in the pool’s selection order, succeeding when one of them takes it. Every copy is the same publication, so a subscriber delivers it once.

Source§

impl Pool

Source

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

Serves o on every link that is up, and on every link that comes up after. It succeeds when one link serves it; each link advertises it naming its own station, and renews it and puts it in the DHT as Link::serve does.

Source§

impl Pool

Source

pub async fn connect(seeds: Vec<Seed>, opts: Opts) -> Result<Pool, PoolError>

Checks seeds and opts, dials every seed, and returns once one link is up, or PoolError::NoLink with each link’s last error when the connect timeout passes first. Links not yet up keep dialing.

Source

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

The node_id the pool links as.

Source

pub fn status(&self) -> Vec<LinkStatus>

Every link the pool holds, seeds first.

Source

pub async fn close(&self)

Ends every link with a GOODBYE and every subscription. It withdraws nothing: an advertisement lapses with its link.

Trait Implementations§

Source§

impl Clone for Pool

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

impl Debug for Pool

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Pool

§

impl !UnwindSafe for Pool

§

impl Freeze for Pool

§

impl Send for Pool

§

impl Sync for Pool

§

impl Unpin for Pool

§

impl UnsafeUnpin for Pool

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