Skip to main content

ReportAssembler

Struct ReportAssembler 

Source
pub struct ReportAssembler<const N: usize> { /* private fields */ }
Expand description

Reassembles a report that arrived as a series of chunks (§10.2.3).

N is the byte budget for the assembled answer. A whole-node wildcard read of a real device is several kilobytes, so this is the one place in the crate where a caller has to size a buffer against what it asked for rather than against a message: the answer is by definition larger than any single message, or it would not have been chunked.

Implementations§

Source§

impl<const N: usize> ReportAssembler<N>

Source

pub const fn new() -> Self

An empty assembler.

Source

pub const fn reset(&mut self)

Forgets everything, for the next read on the same buffer.

Source

pub const fn is_complete(&self) -> bool

Whether the last chunk has arrived.

Source

pub const fn chunks(&self) -> usize

How many messages the answer took.

Source

pub const fn subscription_id(&self) -> Option<u32>

The subscription this report belongs to, if any (§8.5.3.2).

Source

pub fn push(&mut self, report: &ReportData<'_>) -> Result<bool>

Adds one chunk, returning whether the report is now complete.

false means another ReportData is coming — and that the server is waiting for a StatusResponse before it sends one (§10.2.3).

ErrorCode::NoSpace means the answer is larger than N. Nothing partial is kept: half a report is not a smaller report, it is a wrong one.

Source

pub fn reports(&self) -> Reports<'_> ⓘ

Every attribute report the answer carried, in the order it arrived.

Order is part of the answer: §10.6.4.3.1’s list encoding is a clearing block followed by its items, and reordering them would change what the list means.

Source

pub fn assembled(&self) -> &[u8] ⓘ

The assembled answer as one Array element.

Valid TLV once ReportAssembler::is_complete, and forwardable verbatim — a bridge relaying a report it does not understand needs exactly this.

Trait Implementations§

Source§

impl<const N: usize> Debug for ReportAssembler<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize> Default for ReportAssembler<N>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<const N: usize> Forget for ReportAssembler<N>

§

impl<const N: usize> Freeze for ReportAssembler<N>
where [u8; N]: Freeze,

§

impl<const N: usize> Move for ReportAssembler<N>

§

impl<const N: usize> RefUnwindSafe for ReportAssembler<N>
where [u8; N]: RefUnwindSafe,

§

impl<const N: usize> Send for ReportAssembler<N>
where [u8; N]: Send,

§

impl<const N: usize> Sync for ReportAssembler<N>
where [u8; N]: Sync,

§

impl<const N: usize> Unpin for ReportAssembler<N>
where [u8; N]: Unpin,

§

impl<const N: usize> UnsafeUnpin for ReportAssembler<N>
where [u8; N]: UnsafeUnpin,

§

impl<const N: usize> UnwindSafe for ReportAssembler<N>
where [u8; N]: UnwindSafe,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.