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>;
// Provided method
fn new_stream(&mut self) -> (Box<dyn FlowController>, 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.
Provided Methods§
Sourcefn new_stream(&mut self) -> (Box<dyn FlowController>, Promise<(), Error>)
fn new_stream(&mut self) -> (Box<dyn FlowController>, Promise<(), Error>)
Constructs a flow controller for a new stream on this connection.
Returns (fc, p), where fc is the new flow controller and p is a promise that must be polled in order to drive the flow controller.