Struct ockam::pipe2::PipeBuilder
source · [−]pub struct PipeBuilder { /* private fields */ }
Expand description
A builder structure for pipes
A pipe is a unidirectional message sending abstraction, which
optionally provides ordering and delivery guarantees. The two
basic pipe initialisation modes are Fixed
, connecting to a
specific peer route, and Dynamic
, connecting to a handshake
worker which then creates a remote peer dynamically.
Static example
The easiest way to get started with pipes is with a static route.
This requires a running PipeReceiver
worker on a remote system.
Code on machine A:
let result = PipeBuilder::fixed()
.connect(vec![tcp_connection, my_pipe])
.build(ctx)
.await?;
ctx.send(
vec![result.addr(), "app".into()], // Send a message through the pipe to "app"
String::from("Hello you on the other end of this pipe!"),
)
.await?;
Code on machine B:
let receive = PipeBuilder::fixed()
.receive(my_pipe)
.build(ctx)
.await?;
let msg = ctx.receive::<String>().await?;
println!("Message from pipe: {}", msg);
Implementations
sourceimpl PipeBuilder
impl PipeBuilder
sourcepub fn connect<R: Into<Route>>(self, peer: R) -> Self
pub fn connect<R: Into<Route>>(self, peer: R) -> Self
Set a connection peer, creating an outgoing pipe
-
In
fixed
mode this attempts to connect directly to a receiver at the given peer route. -
In
dynamic
mode this initiates a handshake with the given peer. This handshake then resolves to the final receiver
sourcepub fn receive<A: Into<Address>>(self, addr: A) -> Self
pub fn receive<A: Into<Address>>(self, addr: A) -> Self
Set a receiving address, creating a receiving pipe
-
In
fixed
mode this creates a pipe receiver which waits for incoming messages from a sender. -
In
dynamic
mode this spawns a handshake listener, which will create pipe receivers dynamically for any incoming initialisation request
sourcepub fn enforce_ordering(self) -> Self
pub fn enforce_ordering(self) -> Self
Set this pipe to enforce the ordering of incoming messages
sourcepub fn delivery_ack(self) -> Self
pub fn delivery_ack(self) -> Self
Enable the delivery guarantee behaviour on this pipe
Additional behaviours can be added to compose a custom pipe worker.
sourcepub async fn build(self, ctx: &mut Context) -> Result<BuilderResult>
pub async fn build(self, ctx: &mut Context) -> Result<BuilderResult>
Consume this builder and construct a set of pipes
Auto Trait Implementations
impl RefUnwindSafe for PipeBuilder
impl Send for PipeBuilder
impl Sync for PipeBuilder
impl Unpin for PipeBuilder
impl UnwindSafe for PipeBuilder
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