Skip to main content

Provider

Struct Provider 

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

General Provider holding the node processor, RPC dispatcher, and extension registry.

Implementations§

Source§

impl Provider

Source

pub fn from_processor(processor: Arc<Processor>) -> Self

Create provider from processor directly

Source

pub const fn processor(&self) -> &Arc<Processor> ⓘ

Return a reference to the underlying Processor driving this provider.

Source

pub fn register_local_rpc_method( &self, method: impl Into<String>, handler: impl LocalRpcMethod + 'static, ) -> Result<()>

Register an external LocalRpcMethod reachable through Self::request_internal (and C FFI / browser RPC dispatch).

Rejects empty method names, any built-in node/JSON-RPC method name, and duplicate registrations on the same Provider.

Source

pub async fn lookup_registry_raw( &self, topic: &str, ) -> Result<LookupRegistryResponse>

Fetch raw normalized elements of DHT registry topic together with CRDT dot timestamps, local network_id, and local clock now_ms.

Source

pub async fn onion_invoke_raw( &self, request: OnionInvokeRpcRequest, ) -> Result<OnionInvokeRpcResponse>

Evaluate a generic 1-stage Kleisli invoke pipeline over a guard-closed Sphinx loop, optionally restricted to eligible_dids and/or concrete (did, process_epoch) eligible_stages.

Source

pub fn extensions(&self) -> Extensions

The shared protocol registry. The Backend serving core’s application inbox clones this, so registration (via the provider) and dispatch see the same table.

Source

pub fn onion_pipeline(&self) -> Result<OnionPipelineHandle>

Cross-platform handle for registering intermediate invoke backends and evaluating multi-stage Kleisli pipelines on this provider’s onion runtime (#834 Phase 2b).

Source

pub fn dispatch_drop_counters(&self) -> DispatchDropCounters

The application envelopes the Backend dropped instead of dispatching, by reason.

Source

pub fn take_e2e_events(&self) -> Result<TakeE2eEventsResponse>

Drain all retained inbound E2E handshake and stream-frame events.

Source

pub fn signing_horizon(&self) -> DelegationHorizon

Return the active delegation signing horizon of this node.

Source

pub fn renew_delegatee_key( &self, next: DelegateeKey, ) -> Result<DelegationHorizon>

Renew this node’s active session key in process before its signing horizon expires.

Source

pub fn register_protocol<P, I>(&self, protocol: P, interpret: I) -> Result<()>
where P: Protocol + MaybeSendSync + 'static, P::State: MaybeSendSync + 'static, P::Effect: MaybeSendSync, I: Interpret<Effect = P::Effect> + MaybeSendSync + 'static,

Register a pure Protocol together with its Interpret shell under the protocol’s namespace. Errors if the namespace is already taken.

Source

pub async fn send(&self, to: Did, namespace: &str, payload: Bytes) -> Result<()>

Send a namespaced payload to a peer. This is the uniform upper-layer send — a core capability, identical on native and browser.

Source

pub async fn peer_measurement(&self, did: Did) -> Option<PeerMeasurement>

Return local measurement counters for a peer, if observed.

Source

pub async fn peer_measurements(&self) -> Vec<PeerMeasurement>

Return every retained local peer measurement.

Source

pub async fn provisional_evidence_page( &self, after: Option<EvidenceDigest>, limit: NonZeroUsize, ) -> Result<EvidencePage<Did>, EvidenceError>

Return one bounded page of canonical provisional service-receipt evidence.

Source

pub async fn provisional_evidence_counters(&self) -> EvidenceCounters

Return aggregate provisional-evidence counters without account labels.

Source

pub fn origin_quota_counters(&self) -> OriginQuotaCounters

Return aggregate final-destination origin-quota drops by lane and reason.

Source

pub async fn registrations_published(&self)

Resolves once every registration of this node is stored at its owners, as they reported it (Processor::registrations_published, #866).

Source

pub async fn leave(&self) -> Result<()>

Best-effort voluntary departure (#1057): hand off live relay carriers to remaining members and send Leave { successor_list } to this node’s predecessor and successor head before transports close.

Source

pub async fn close(self) -> Result<()>

Close this node and release every store it holds, so that the stores can be opened again in this process: an in-process re-init (#1085).

Law (close): the steps run in this order, each once the one before it has ended.

  (a) stop     every node task is told to end; every listener generation ends
  (b) drain    no node task is live (the one-spawn law of `crate::tasks`)
  (c) network  every connection is closed, and no new one is admitted (#1098)
  (d) flush    the measurements are persisted
  (e) release  no node task is live again; the last clone of the node drops, and with
               it every store

Steps (c) and (d) are Processor::close. A node task spawned after (b), during (c) or (d) (by a callback of the closing network, say), starts with the stop already fired: it ends at its first suspension point, or winds down within its bound. (e) drains again before the release, so no such task holds the node into it.

Post: Ok means every store the node was built over is released and its directory unlocked (the release law of rings_core::storage::file), so an open of those stores in this process succeeds. Err(Error::ProviderStillShared { released }) means another clone of the node, a Provider or the Processor it shares, is still held. Steps (a) to (d) have run, so the node is stopped and its network closed. Its stores are released only when the last clone drops, and released resolves then. Any other Err is the first failure of step (c) or (d); step (e) has run all the same, so the stores are released. On the shared path a failure of (c) or (d) is logged, since released is what the caller needs next.

Bound: no step waits on a timer of its own: each is woken by the end it awaits. (a) and (b) last one suspension of each node task. A task winding down at the stop (a relay resetting its socket and sending its session’s close) adds a send, bounded by the send timeout, and a listener generation adds its measurement flush. (c) is the swarm’s close of its connections. (e) also awaits the tasks the core detached that still hold a part of the node. Each of those either ends with the dropped node (an inbound actor, the outbound workers, whose channels close with it), is bounded by its own timeout (a handshake, a payload send), or is a replay transition or flush, which ends after its write.

Source

pub fn set_backend(&self) -> Result<()>

Serve the swarm’s application inbox with the extension Backend on a detached task, so inbound custom messages are decoded as Envelopes and routed to their namespace’s protocol. Call once, after registering every protocol whose messages may already be on their way (relay mail included): from the claim on, an envelope of a namespace not yet registered is dropped, counted. The inbox is claimed once, so a second call fails with ApplicationInboxClaimed. Serving lasts until the node is closed (Provider::close): the service is a node task (#1085). Use application_service for one under a stop of the caller’s. Spawn the application-inbox consumer over this provider’s protocol registry.

Source

pub fn set_backend_with_observer( &self, observer: Arc<dyn BackendObserver>, ) -> Result<()>

Spawn the application-inbox consumer with an explicit BackendObserver.

Source

pub fn application_service( &self, observer: Option<Arc<dyn BackendObserver>>, stop: StopToken, ) -> Result<impl Future<Output = ()> + 'static>

Claim the swarm’s application inbox now and return the future that serves it with the extension Backend over this provider’s protocol registry, handing peer facts and unrouted E2E messages to observer, until the swarm is gone or stop is requested.

  application_service(o, s) = claim inbox  ;  pure (serve_o(inbox, s))
  serve_o                    = Backend::new(self).observed_by(o).serve

The claim is eager, so data that arrives before the caller spawns the future waits in the inbox instead of being discarded unclaimed; the caller owns only the spawner and the stop token. As with set_backend, register protocols first: an envelope of a namespace not yet registered when it is read is dropped, counted. The inbox is claimed once (see Swarm::application_inbox), so a second call fails.

Source

pub async fn request_internal( &self, method: String, params: Value, ) -> Result<Value>

Request local rpc interface the internal rpc interface is provide by rings_rpc

Source§

impl Provider

Source

pub async fn request<T>(&self, method: Method, params: T) -> Result<Value>
where T: Serialize,

A request function implementation for native provider

Source

pub async fn listen(&self) -> Result<()>

Listen for messages until this future is dropped or aborted.

This is a long-running task; do not await completion as a readiness signal. Listening publishes the processor’s registrations, so a role that registers relay first installs its onion runtime (install_relay_onion_runtime).

Source

pub async fn listen_with(&self, stop: StopToken) -> Result<()>

Listen for messages until stop requests cooperative shutdown.

This is a long-running task; do not await completion as a readiness signal. Like Self::listen, it first installs the onion runtime of a role that registers relay.

Source

pub fn onion_circuit(&self) -> Result<NativeOnionCircuitHandle>

The native handle of this provider’s onion runtime. The runtime is installed in this provider’s registry on first use, once for all its clones, and shared afterwards.

§Errors

Error::Lock for a poisoned runtime slot, or a registry or runtime failure of the install.

Trait Implementations§

Source§

impl Clone for Provider

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
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> 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<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