Trait capnp_rpc::Connection
source · pub trait Connection<VatId> {
// Required methods
fn get_peer_vat_id(&self) -> VatId;
fn new_outgoing_message(
&mut self,
first_segment_word_size: u32
) -> Box<dyn OutgoingMessage>;
fn receive_incoming_message(
&mut self
) -> Promise<Option<Box<dyn IncomingMessage>>, Error>;
fn shutdown(&mut self, result: Result<()>) -> Promise<(), Error>;
}
Expand description
A two-way RPC connection.
A connection can be created by VatNetwork::connect()
.
Required Methods§
sourcefn get_peer_vat_id(&self) -> VatId
fn get_peer_vat_id(&self) -> VatId
Returns the connected vat’s authenticated VatId. It is the VatNetwork’s responsibility to authenticate this, so that the caller can be assured that they are really talking to the identified vat and not an imposter.
sourcefn new_outgoing_message(
&mut self,
first_segment_word_size: u32
) -> Box<dyn OutgoingMessage>
fn new_outgoing_message( &mut self, first_segment_word_size: u32 ) -> Box<dyn OutgoingMessage>
Allocates a new message to be sent on this connection.
If first_segment_word_size
is non-zero, it should be treated as a
hint suggesting how large to make the first segment. This is entirely
a hint and the connection may adjust it up or down. If it is zero,
the connection should choose the size itself.
sourcefn receive_incoming_message(
&mut self
) -> Promise<Option<Box<dyn IncomingMessage>>, Error>
fn receive_incoming_message( &mut self ) -> Promise<Option<Box<dyn IncomingMessage>>, Error>
Waits for a message to be received and returns it. If the read stream cleanly terminates, returns None. If any other problem occurs, returns an Error.