Skip to main content

Indication

Trait Indication 

pub trait Indication: for<'a> TryFrom<&'a Message, Error = DecodeError> {
    type Service: Service;

    const IDS: &'static [u16];
}
Expand description

A message that a service sends as an indication.

Receive it with Client::indications. A type with several IDS returns DecodeError::UnexpectedMessage for any other message ID.

§Example

use ql_qmi::codec::{DecodeError, Indication};
use ql_qmi::{Message, Service};

/// Device Management Service.
pub struct Dms;

impl Service for Dms {
    const ID: u32 = 0x02;
    const VERSION: u8 = 1;
}

/// An event report of the Device Management Service.
struct EventReport {
    operating_mode: Option<u8>,
}

impl Indication for EventReport {
    const IDS: &'static [u16] = &[0x0001];
    type Service = Dms;
}

impl TryFrom<&Message> for EventReport {
    type Error = DecodeError;

    fn try_from(message: &Message) -> Result<Self, DecodeError> {
        Ok(Self {
            operating_mode: message.optional(0x14)?,
        })
    }
}

Required Associated Constants§

const IDS: &'static [u16]

Message IDs of the indications that this type decodes.

Required Associated Types§

type Service: Service

Service that sends the indication.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§