pub struct Unnamed<S>(/* private fields */);Expand description
The stand-in a definition carries while its subscription has no name yet.
#[subscriber] and #[subscriber(Kind)] fix the subscription kind and leave its value to
the mount site, so the definition’s source starts as Unnamed<Kind>. It implements no
SubscriptionSource: mounting a definition that was never named is a compile
error, not a startup one. name replaces it with
the kind itself, built through FromName.
§Examples
use ruststream::memory::prelude::*;
use serde::Deserialize;
#[derive(Deserialize)]
struct Order {
id: u64,
}
/// The kind is fixed here; its source stays `Unnamed<MemorySource>` until the mount names it.
#[subscriber(MemorySource)]
async fn audit(order: &Order) -> HandlerOutcome {
tracing::info!(order.id, "audited");
HandlerOutcome::ack()
}
fn app(region: &str) -> RustStream {
RustStream::new(AppInfo::new("audit", "0.1.0")).with_broker(MemoryBroker::new(), |b| {
b.include(audit.name(format!("orders.{region}")));
})
}A definition mounted without a name does not compile:
ⓘ
use ruststream::memory::prelude::*;
use serde::Deserialize;
#[derive(Deserialize)]
struct Order {
id: u64,
}
#[subscriber(MemorySource)]
async fn audit(order: &Order) -> HandlerOutcome {
tracing::info!(order.id, "audited");
HandlerOutcome::ack()
}
fn app() -> RustStream {
RustStream::new(AppInfo::new("audit", "0.1.0")).with_broker(MemoryBroker::new(), |b| {
// Never named: there is no subscription to open.
b.include(audit);
})
}Implementations§
Trait Implementations§
impl<S> Copy for Unnamed<S>
Auto Trait Implementations§
impl<S> Freeze for Unnamed<S>
impl<S> RefUnwindSafe for Unnamed<S>
impl<S> Send for Unnamed<S>
impl<S> Sync for Unnamed<S>
impl<S> Unpin for Unnamed<S>
impl<S> UnsafeUnpin for Unnamed<S>
impl<S> UnwindSafe for Unnamed<S>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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 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> ⓘ
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