Skip to main content

ReportDataHandler

Trait ReportDataHandler 

Source
pub trait ReportDataHandler {
    // Required method
    fn handle_report(
        &self,
        ctx: impl ReportContext,
        report: &ReportDataResp<'_>,
    ) -> impl Future<Output = Result<(), IMStatusCode>>;
}
Expand description

A handler for consuming server-initiated ReportData messages — the controller/subscriber side of the Interaction Model.

After a controller establishes a subscription (via the IM client), the publisher pushes ReportData messages on fresh inbound exchanges throughout the subscription’s lifetime. The InteractionModel accepts those exchanges (it already owns all inbound IM traffic), parses each ReportData chunk, ACKs it at the IM layer, and hands the parsed chunk to this trait via handle_report.

The report handler is a separate, peer capability of the [InteractionModel], alongside the [DataModel] cluster handler — not a supertrait of DataModel. A pure accessory does not supply one: the InteractionModel’s report handler defaults to (), whose implementation disowns every inbound report with IMStatusCode::InvalidSubscription (the same status the C++ SDK returns for an unmatched report, which the publisher uses to tear a stale subscription down). A controller injects a real one via InteractionModel::new_with_reports.

handle_report is invoked once per received chunk with a ReportContext (a HandlerContext carrying the originating exchange and the subscription identity) plus the parsed ReportDataResp (borrowing the exchange RX buffer). The InteractionModel owns the multi-chunk loop and the inter-chunk StatusResponse(Success) acks; a handler that cares about chunk boundaries reads report.more_chunks and reassembles across calls itself.

Required Methods§

Source

fn handle_report( &self, ctx: impl ReportContext, report: &ReportDataResp<'_>, ) -> impl Future<Output = Result<(), IMStatusCode>>

Handle a single received ReportData chunk.

Returning Ok(()) makes the InteractionModel reply StatusResponse(Success); returning Err(code) makes it reply StatusResponse(code) (e.g. IMStatusCode::InvalidSubscription to disown a subscription the controller no longer tracks).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl ReportDataHandler for ()

The accessory-role default report handler: a device that never subscribes to anything disowns every inbound report with IMStatusCode::InvalidSubscription. This is the default type of the InteractionModel’s report-handler generic, so existing accessory call sites are unaffected.

Source§

async fn handle_report( &self, _ctx: impl ReportContext, _report: &ReportDataResp<'_>, ) -> Result<(), IMStatusCode>

Source§

impl<T> ReportDataHandler for &T

Source§

fn handle_report( &self, ctx: impl ReportContext, report: &ReportDataResp<'_>, ) -> impl Future<Output = Result<(), IMStatusCode>>

Source§

impl<T> ReportDataHandler for &mut T

Source§

fn handle_report( &self, ctx: impl ReportContext, report: &ReportDataResp<'_>, ) -> impl Future<Output = Result<(), IMStatusCode>>

Implementors§