pub struct Provider { /* private fields */ }Expand description
General Provider holding the node processor, RPC dispatcher, and extension registry.
Implementations§
Source§impl Provider
impl Provider
Sourcepub fn from_processor(processor: Arc<Processor>) -> Self
pub fn from_processor(processor: Arc<Processor>) -> Self
Create provider from processor directly
Sourcepub const fn processor(&self) -> &Arc<Processor> ⓘ
pub const fn processor(&self) -> &Arc<Processor> ⓘ
Return a reference to the underlying Processor driving this provider.
Sourcepub fn register_local_rpc_method(
&self,
method: impl Into<String>,
handler: impl LocalRpcMethod + 'static,
) -> Result<()>
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.
Sourcepub async fn lookup_registry_raw(
&self,
topic: &str,
) -> Result<LookupRegistryResponse>
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.
Sourcepub async fn onion_invoke_raw(
&self,
request: OnionInvokeRpcRequest,
) -> Result<OnionInvokeRpcResponse>
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.
Sourcepub fn extensions(&self) -> Extensions
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.
Sourcepub fn onion_pipeline(&self) -> Result<OnionPipelineHandle>
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).
Sourcepub fn dispatch_drop_counters(&self) -> DispatchDropCounters
pub fn dispatch_drop_counters(&self) -> DispatchDropCounters
The application envelopes the Backend dropped instead of dispatching, by reason.
Sourcepub fn take_e2e_events(&self) -> Result<TakeE2eEventsResponse>
pub fn take_e2e_events(&self) -> Result<TakeE2eEventsResponse>
Drain all retained inbound E2E handshake and stream-frame events.
Sourcepub fn signing_horizon(&self) -> DelegationHorizon
pub fn signing_horizon(&self) -> DelegationHorizon
Return the active delegation signing horizon of this node.
Sourcepub fn renew_delegatee_key(
&self,
next: DelegateeKey,
) -> Result<DelegationHorizon>
pub fn renew_delegatee_key( &self, next: DelegateeKey, ) -> Result<DelegationHorizon>
Renew this node’s active session key in process before its signing horizon expires.
Sourcepub 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,
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,
Sourcepub async fn send(&self, to: Did, namespace: &str, payload: Bytes) -> Result<()>
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.
Sourcepub async fn peer_measurement(&self, did: Did) -> Option<PeerMeasurement>
pub async fn peer_measurement(&self, did: Did) -> Option<PeerMeasurement>
Return local measurement counters for a peer, if observed.
Sourcepub async fn peer_measurements(&self) -> Vec<PeerMeasurement>
pub async fn peer_measurements(&self) -> Vec<PeerMeasurement>
Return every retained local peer measurement.
Sourcepub async fn provisional_evidence_page(
&self,
after: Option<EvidenceDigest>,
limit: NonZeroUsize,
) -> Result<EvidencePage<Did>, EvidenceError>
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.
Sourcepub async fn provisional_evidence_counters(&self) -> EvidenceCounters
pub async fn provisional_evidence_counters(&self) -> EvidenceCounters
Return aggregate provisional-evidence counters without account labels.
Sourcepub fn origin_quota_counters(&self) -> OriginQuotaCounters
pub fn origin_quota_counters(&self) -> OriginQuotaCounters
Return aggregate final-destination origin-quota drops by lane and reason.
Sourcepub async fn registrations_published(&self)
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).
Sourcepub async fn leave(&self) -> Result<()>
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.
Sourcepub async fn close(self) -> Result<()>
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 storeSteps (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.
Sourcepub fn set_backend(&self) -> Result<()>
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.
Sourcepub fn set_backend_with_observer(
&self,
observer: Arc<dyn BackendObserver>,
) -> Result<()>
pub fn set_backend_with_observer( &self, observer: Arc<dyn BackendObserver>, ) -> Result<()>
Spawn the application-inbox consumer with an explicit BackendObserver.
Sourcepub fn application_service(
&self,
observer: Option<Arc<dyn BackendObserver>>,
stop: StopToken,
) -> Result<impl Future<Output = ()> + 'static>
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).serveThe 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§impl Provider
impl Provider
Sourcepub async fn request<T>(&self, method: Method, params: T) -> Result<Value>where
T: Serialize,
pub async fn request<T>(&self, method: Method, params: T) -> Result<Value>where
T: Serialize,
A request function implementation for native provider
Sourcepub async fn listen(&self) -> Result<()>
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).
Sourcepub async fn listen_with(&self, stop: StopToken) -> Result<()>
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.
Sourcepub fn onion_circuit(&self) -> Result<NativeOnionCircuitHandle>
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§
Auto Trait Implementations§
impl !RefUnwindSafe for Provider
impl !UnwindSafe for Provider
impl Forget for Provider
impl Freeze for Provider
impl Move for Provider
impl Send for Provider
impl Sync for Provider
impl Unpin for Provider
impl UnsafeUnpin for Provider
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T> MaybeSend for T
impl<T> MaybeSendSync for T
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.