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§
Sourcefn closed<'a>(
&'a self,
) -> Pin<Box<dyn Future<Output = Result<(), Status>> + 'a>>
fn closed<'a>( &'a self, ) -> Pin<Box<dyn Future<Output = Result<(), Status>> + 'a>>
Returns a future that resolves when the connection is closed.
Sourcefn connection_type(&self) -> ConnectionBackendType
fn connection_type(&self) -> ConnectionBackendType
Returns the type of the connection backend.
Sourcefn write(&self, bytes: &[u8]) -> Result<usize, Status>
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.
Sourcefn into_fidl_channel(self: Box<Self>) -> Result<Channel, Status>
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.