pub struct FilePublisher { /* private fields */ }Expand description
Publishes messages into the stream file.
User headers travel in a text-safe envelope applied only when headers are present, so a file written without headers stays readable as a plain payload stream by other tools.
A publish carries no per-message settings: an append to a stream file takes a key and a
payload and nothing else, so Publisher::Options is the unit type and the publish builder
gains no step from this crate.
A destination is a stream key inside the broker, and the file itself is named once, in
FileBroker::new. The
FilePublish
page shows it in a service.
§Examples
A reply type declares its stream key, and the subscriber carries the bare reply clause:
use ruststream_sea_file::file::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize)]
struct Order {
id: u64,
}
#[derive(Debug, Outgoing, Serialize)]
#[outgoing(name = "receipts")]
struct Receipt {
order: u64,
}
#[subscriber(FileStream::new("orders"), reply)]
async fn confirm(order: &Order) -> Receipt {
tracing::info!(order.id, "confirmed");
Receipt { order: order.id }
}
#[ruststream::app]
fn app() -> impl App {
RustStream::new(AppInfo::new("orders", "0.1.0"))
.with_broker(FileBroker::new("/tmp/orders.ss"), |b| {
b.include(confirm).out_reply(Publish);
})
}Trait Implementations§
Source§impl Clone for FilePublisher
impl Clone for FilePublisher
Source§impl Debug for FilePublisher
impl Debug for FilePublisher
Source§impl Publisher for FilePublisher
impl Publisher for FilePublisher
Source§type Payload = Lend
type Payload = Lend
The append reads the bytes and keeps nothing: the client’s send_to takes a slice, and
the envelope this crate writes is a buffer of its own anyway.
Source§type Error = SeaFileError
type Error = SeaFileError
publish.Source§type Options = ()
type Options = ()
QoS, a priority, an ordering key, whatever this
transport lets one message differ from the next in. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for FilePublisher
impl !UnwindSafe for FilePublisher
impl Freeze for FilePublisher
impl Send for FilePublisher
impl Sync for FilePublisher
impl Unpin for FilePublisher
impl UnsafeUnpin for FilePublisher
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
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> ⓘ
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<P> PublishExt for P
impl<P> PublishExt for P
Source§fn message<'a, T>(
&'a self,
value: &'a T,
) -> PublishBuilder<&'a Self, MessageBody<'a, T>, UnnamedCodec, HeadersUnset, <T as OutgoingDestination>::Form>where
T: OutgoingDestination,
fn message<'a, T>(
&'a self,
value: &'a T,
) -> PublishBuilder<&'a Self, MessageBody<'a, T>, UnnamedCodec, HeadersUnset, <T as OutgoingDestination>::Form>where
T: OutgoingDestination,
#[derive(Outgoing)] value, encoded with the crate’s
default codec (name another one with with_codec(..)). A
Serialized value’s bytes leave as they are instead - the wire is
the type’s own (MessageWire), and no codec runs on it. Read moreSource§fn begin(
&self,
) -> impl Future<Output = Result<TransactionScope<'_, Self, UnnamedCodec, AnyDeclared>, Self::Error>> + Sendwhere
Self: Sized + TransactionalPublisher,
fn begin(
&self,
) -> impl Future<Output = Result<TransactionScope<'_, Self, UnnamedCodec, AnyDeclared>, Self::Error>> + Sendwhere
Self: Sized + TransactionalPublisher,
TransactionScope that
owns it. Read moreSource§fn owned_transaction(
&self,
) -> impl Future<Output = Result<TypedTransaction<Self::Transaction, UnnamedCodec, AnyDeclared>, Self::Error>> + Sendwhere
Self: Sized + OwnedTransactions,
fn owned_transaction(
&self,
) -> impl Future<Output = Result<TypedTransaction<Self::Transaction, UnnamedCodec, AnyDeclared>, Self::Error>> + Sendwhere
Self: Sized + OwnedTransactions,
TypedTransaction that owns it. Read more