pub struct Stream { /* private fields */ }
Expand description
Ockam stream protocol controller
Each stream has a sending and consuming worker (publisher and consumer) that are created and managed on the fly by this abstraction.
Implementations
sourceimpl Stream
impl Stream
sourcepub async fn new(ctx: &Context) -> Result<Self>
pub async fn new(ctx: &Context) -> Result<Self>
Create a new Ockam stream controller
By default, the created stream will poll for new messages every 250 milliseconds.
sourcepub fn with_interval<D: Into<Duration>>(self, duration: D) -> Self
pub fn with_interval<D: Into<Duration>>(self, duration: D) -> Self
Customize the polling interval for the stream consumer
sourcepub fn stream_service<S: Into<String>>(self, serv: S) -> Self
pub fn stream_service<S: Into<String>>(self, serv: S) -> Self
Specify the stream service running on the remote
sourcepub fn index_service<S: Into<String>>(self, serv: S) -> Self
pub fn index_service<S: Into<String>>(self, serv: S) -> Self
Specify the index service running on the remote
sourcepub fn client_id<S: Into<String>>(self, client_id: S) -> Self
pub fn client_id<S: Into<String>>(self, client_id: S) -> Self
Specify the client_id for the stream consumer
When setting up a stream without calling this function a random client id will be assigned.
sourcepub fn with_recipient<A: Into<Address>>(self, addr: A) -> Self
pub fn with_recipient<A: Into<Address>>(self, addr: A) -> Self
Specify an address to forward incoming messages to
When setting up a stream without calling this function
messages will be buffered by the StreamConsumer and must be
polled via the StreamWorkerCmd
.
sourcepub async fn connect<R, S>(
&self,
route: R,
sender_name: S,
receiver_name: S
) -> Result<(SenderAddress, ReceiverAddress)> where
R: Into<Route>,
S: Into<String>,
pub async fn connect<R, S>(
&self,
route: R,
sender_name: S,
receiver_name: S
) -> Result<(SenderAddress, ReceiverAddress)> where
R: Into<Route>,
S: Into<String>,
Connect to a bi-directional stream by remote and stream pair
When using the stream protocol for bi-directional communication a sending and receiving stream name is required. These two identifiers MUST be known between nodes that wish to exchange messages.
The route
parameter is the route to a remote which hosts a
stream_service
and stream_index_service
, such as
hub.ockam.io.
Streams that do not already exists will be created, and existing stream identifiers will automatically be re-used.
Auto Trait Implementations
impl !RefUnwindSafe for Stream
impl Send for Stream
impl Sync for Stream
impl Unpin for Stream
impl !UnwindSafe for Stream
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more