Skip to main content

Connection

Trait Connection 

Source
pub trait Connection:
    Stream<Item = Result<Vec<u8>, Status>>
    + Sink<Vec<u8>, Error = Status>
    + Send
    + Sync
    + Debug
    + Unpin {
    // Required methods
    fn closed<'a>(
        &'a self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Status>> + 'a>>;
    fn connection_type(&self) -> ConnectionBackendType;
    fn write(&self, bytes: &[u8]) -> Result<usize, Status>;
    fn is_closed(&self) -> bool;
    fn into_fidl_channel(self: Box<Self>) -> Result<Channel, Status>;
}
Expand description

A trait representing a Bluetooth data connection. Concrete implementations handle the specific transport mechanism (e.g., socket or FIDL protocol) while fulfilling the Sink and Stream contracts for data transfer.

Required Methods§

Source

fn closed<'a>( &'a self, ) -> Pin<Box<dyn Future<Output = Result<(), Status>> + 'a>>

Returns a future that resolves when the connection is closed.

Source

fn connection_type(&self) -> ConnectionBackendType

Returns the type of the connection backend.

Source

fn write(&self, bytes: &[u8]) -> Result<usize, Status>

Writes data to the connection. This is a non-blocking fast path. Returns SHOULD_WAIT if the buffer is full.

Source

fn is_closed(&self) -> bool

Returns true if the connection is currently closed.

Source

fn into_fidl_channel(self: Box<Self>) -> Result<Channel, Status>

Consumes the connection and returns a partially filled FIDL channel containing the transport (e.g., socket handle) if applicable.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§