Struct ockam_transport_ble::BleTransport
source · pub struct BleTransport { /* private fields */ }
Expand description
High level management interface for BLE transports
Be aware that only one BleTransport
can exist per node, as it
registers itself as a router for the BLE
address type. Multiple
calls to BleTransport::create
will panic.
To register additional connections on an already initialised
BleTransport
, use
ble.connect()
. To listen for
incoming connections use
ble.listen()
use ockam_transport_ble::{BleClient, BleTransport};
use ockam_transport_ble::driver::btleplug::BleAdapter;
// Create a ble_client
let ble_adapter = BleAdapter::try_new().await?;
let ble_client = BleClient::with_adapter(ble_adapter);
// Initialize the BLE Transport.
let ble = BleTransport::create(&ctx).await?;
// Try to connect to BleServer
ble.connect(ble_client, "ockam_ble_1".to_string()).await?;
Implementations§
source§impl BleTransport
impl BleTransport
sourcepub async fn create(ctx: &Context) -> Result<Self>
pub async fn create(ctx: &Context) -> Result<Self>
Create a new BLE transport and router for the current node
sourcepub async fn connect<A: BleClientDriver + BleStreamDriver + Send + 'static, S: AsRef<str> + Debug>(
&self,
ble_client: BleClient<A>,
peer: S,
) -> Result<()>
pub async fn connect<A: BleClientDriver + BleStreamDriver + Send + 'static, S: AsRef<str> + Debug>( &self, ble_client: BleClient<A>, peer: S, ) -> Result<()>
Establish an outgoing BLE connection on an existing transport
Starts a new pair of Ble connection workers
One worker handles outgoing messages, while another handles incoming messages. The local worker address is chosen based on the peer the worker is meant to be connected to.
Trait Implementations§
source§impl AsyncTryClone for BleTransport
impl AsyncTryClone for BleTransport
Auto Trait Implementations§
impl Freeze for BleTransport
impl !RefUnwindSafe for BleTransport
impl Send for BleTransport
impl Sync for BleTransport
impl Unpin for BleTransport
impl !UnwindSafe for BleTransport
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more