Struct bluer::agent::Agent

source ·
pub struct Agent {
    pub request_default: bool,
    pub request_pin_code: Option<RequestPinCodeFn>,
    pub display_pin_code: Option<DisplayPinCodeFn>,
    pub request_passkey: Option<RequestPasskeyFn>,
    pub display_passkey: Option<DisplayPasskeyFn>,
    pub request_confirmation: Option<RequestConfirmationFn>,
    pub request_authorization: Option<RequestAuthorizationFn>,
    pub authorize_service: Option<AuthorizeServiceFn>,
    /* private fields */
}
Available on crate feature bluetoothd only.
Expand description

Bluetooth authorization agent handler.

Each handler that is set to None will reject the request. The capabilities of the agent are published accordingly. Setting all handlers to None (the default) will result in a NoInputNoOutput handler that accepts all requests.

The future of a particular request is dropped when BlueZ cancels that request.

Use Session::register_agent to register the handler.

Fields§

§request_default: bool

This requests is to make the application agent the default agent.

Special permission might be required to become the default agent.

§request_pin_code: Option<RequestPinCodeFn>

This method gets called when the service daemon needs to get the passkey for an authentication.

The return value should be a string of 1-16 characters length. The string can be alphanumeric.

§display_pin_code: Option<DisplayPinCodeFn>

This method gets called when the service daemon needs to display a pin code for an authentication.

An empty reply should be returned. When the pin code needs no longer to be displayed, the Cancel method of the agent will be called.

This is used during the pairing process of keyboards that don’t support Bluetooth 2.1 Secure Simple Pairing, in contrast to DisplayPasskey which is used for those that do.

This method will only ever be called once since older keyboards do not support typing notification.

Note that the PIN will always be a 6-digit number, zero-padded to 6 digits. This is for harmony with the later specification.

§request_passkey: Option<RequestPasskeyFn>

This method gets called when the service daemon needs to get the passkey for an authentication.

The return value should be a numeric value between 0-999999.

§display_passkey: Option<DisplayPasskeyFn>

This method gets called when the service daemon needs to display a passkey for an authentication.

The entered parameter indicates the number of already typed keys on the remote side.

An empty reply should be returned. When the passkey needs no longer to be displayed, the Cancel method of the agent will be called.

During the pairing process this method might be called multiple times to update the entered value.

Note that the passkey will always be a 6-digit number, so the display should be zero-padded at the start if the value contains less than 6 digits.

§request_confirmation: Option<RequestConfirmationFn>

This method gets called when the service daemon needs to confirm a passkey for an authentication.

To confirm the value it should return an empty reply or an error in case the passkey is invalid.

Note that the passkey will always be a 6-digit number, so the display should be zero-padded at the start if the value contains less than 6 digits.

§request_authorization: Option<RequestAuthorizationFn>

This method gets called to request the user to authorize an incoming pairing attempt which would in other circumstances trigger the just-works model, or when the user plugged in a device that implements cable pairing.

In the latter case, the device would not be connected to the adapter via Bluetooth yet.

§authorize_service: Option<AuthorizeServiceFn>

This method gets called when the service daemon needs to authorize a connection/service request.

Trait Implementations§

source§

impl Default for Agent

source§

fn default() -> Agent

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Agent

§

impl !RefUnwindSafe for Agent

§

impl Send for Agent

§

impl Sync for Agent

§

impl Unpin for Agent

§

impl !UnwindSafe for Agent

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.