Trait rubble::att::AttributeProvider[][src]

pub trait AttributeProvider {
    fn for_attrs_in_range(
        &mut self,
        range: HandleRange,
        f: impl FnMut(&Self, &Attribute<dyn AsRef<[u8]>>) -> Result<(), Error>
    ) -> Result<(), Error>;
fn is_grouping_attr(&self, uuid: AttUuid) -> bool;
fn group_end(&self, handle: Handle) -> Option<&Attribute<dyn AsRef<[u8]>>>; fn attr_access_permissions(
        &self,
        _handle: Handle
    ) -> AttributeAccessPermissions { ... }
fn write_attr(&mut self, _handle: Handle, _data: &[u8]) -> Result<(), Error> { ... }
fn read_attr_dynamic(
        &mut self,
        _handle: Handle,
        _buffer: &mut [u8]
    ) -> Option<usize> { ... }
fn prepare_write_attr(
        &mut self,
        _handle: Handle,
        _offset: u16,
        _data: &[u8]
    ) -> Result<(), Error> { ... }
fn execute_write_attr(&mut self, _flags: u8) -> Result<(), Error> { ... }
fn find_information(
        &mut self,
        _range: HandleRange,
        _responder: &mut Sender<'_>
    ) -> Result<(), Error> { ... } }
Expand description

Trait for attribute sets that can be hosted by an AttributeServer.

Required methods

Calls a closure f with every attribute whose handle is inside range, ascending.

If f returns an error, this function will stop calling f and propagate the error upwards. If f returns Ok(()), iteration will continue.

This function would ideally return an iterator instead of invoking a callback, but it’s not currently possible to express the iterator type generically (it would need lifetime-generic associated types), and all workarounds seem to be severely limiting.

Returns whether uuid is a valid grouping attribute type that can be used in Read By Group Type requests.

Queries the last attribute that is part of the attribute group denoted by the grouping attribute at handle.

If handle does not refer to a grouping attribute, returns None.

Groups themselves are collections of attributes. An attribute is in exactly zero or one groups.

For primary services and secondary services, the BLE specification gives exact definitions of what’s in the group. The group begins with the “primary service” or “secondary service” attribute, is followed by the various attributes contained within that service, and ends with the last attribute contained within that service.

TODO: document what the BLE spec has to say about grouping for characteristics.

Provided methods

Retrieves the permissions for the given attribute.

These are used purely for access control within rubble, and won’t be communicated with clients. They should be coordinated beforehand as part of a larger protocol.

Defaults to read-only. If this is overwritten and some attributes are made writeable, write_attribute must be implemented as well.

Attempts to write data to the given attribute.

This will only be called on handles for which attribute_access_permissions returns AttributeAccessPermissions::Writeable or AttributeAccessPermissions::ReadableAndWriteable.

By default, panics on all writes. This must be overwritten if attribute_access_permissions is.

If this read is from dynamic data fill the buffer and return the length of the data. If not return None.

Currently the buffer is 256 bytes.

By default returns None.

In order to write data longer than what would fit one write request the procedure is explained in BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part F section 3.4.6.

In order to write data longer than what would fit one write request the procedure is explained in BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part F section 3.4.6.

See BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part F section 3.4.3.1 on what to implement here.

Implementors