pub struct Backend { /* private fields */ }Expand description
Backend consumes the swarm’s application inbox: it routes each inbound custom message,
decoded as an Envelope, to its namespace’s protocol via the
Extensions registry, and hands everything else to the optional BackendObserver. The
registry is shared with the Provider, so protocols registered there are visible to
inbound dispatch here. Each protocol’s interpreter does its IO through a namespace-scoped
Scope.
The swarm never waits on the backend (#935): it reads at its own pace, and a full inbox drops further live messages. Each registered namespace is dispatched by its own task, in the order its messages arrived, so a protocol waiting on a slow send holds back neither another namespace nor the peer facts; a namespace whose queue is full drops further messages, counted, as the inbox does. Facts and E2E messages go to the observer at once, so a fact can overtake a custom message still queued for its namespace.
Every message the backend drops is counted in the provider’s
dispatch_drop_counters.
Implementations§
Source§impl Backend
impl Backend
Sourcepub fn new(provider: Arc<Provider>) -> Self
pub fn new(provider: Arc<Provider>) -> Self
Create a new backend over a provider, sharing its protocol registry.
Sourcepub fn observed_by(self, observer: Arc<dyn BackendObserver>) -> Self
pub fn observed_by(self, observer: Arc<dyn BackendObserver>) -> Self
Attach the observer that receives peer facts and E2E messages.
Sourcepub async fn serve(self, inbox: ApplicationInbox, stop: StopToken)
pub async fn serve(self, inbox: ApplicationInbox, stop: StopToken)
Consume inbox until the swarm is gone or stop is requested; the namespace workers it
starts end with it once stop is requested.
Auto Trait Implementations§
impl !RefUnwindSafe for Backend
impl !UnwindSafe for Backend
impl Forget for Backend
impl Freeze for Backend
impl Move for Backend
impl Send for Backend
impl Sync for Backend
impl Unpin for Backend
impl UnsafeUnpin for Backend
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
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.