Skip to main content

ReadCursor

Struct ReadCursor 

Source
pub struct ReadCursor { /* private fields */ }
Expand description

Where a chunked read stopped, and where its next message resumes.

Core §10.2.3 splits a report “into multiple messages at logical boundaries due to the size limitations imposed by IPv6 for UDP packets”, and §4.4.4 fixes that size at the 1280-octet IPv6 minimum MTU. A whole-node wildcard does not fit in one message and is not supposed to: it is chunked, “maximally packing” information blocks into each message, with MoreChunkedMessages set on every message but the last.

A cursor is three positions: which request path is being served, how far into that path’s wildcard expansion, and — when one list attribute is itself too big for a message — how many of its items have gone out. It is Copy and holds no borrows, so a device can park one between messages while it waits for the StatusResponse that §10.2.3 requires before the next chunk.

let mut cursor = ReadCursor::START;
while !cursor.is_done() {
    let (bytes, outcome) = server.serve_chunk(
        paths.iter().copied().map(Ok), &InteractionContext::default(),
        None, &mut cursor, scratch, buf)?;
    send(bytes);
    // §10.2.3: "each data message requires a response before the next data message
    // can be sent" — await the StatusResponse here.
    let _ = outcome;
}

Implementations§

Source§

impl ReadCursor

Source

pub const START: Self

The start of a read: nothing served yet.

Source

pub const fn set_event_from(&mut self, number: u64)

Starts the event half of a report at number (§8.5.3.4’s bookmark).

Source

pub const fn event_from(&self) -> u64

The lowest event number this cursor has not reported.

For a device driving Server::serve_chunk_with_events itself. A subscription’s bookmark is kept by the subscription — Server::report_chunk records it and Subscription::reported applies it — so that it moves with what actually went out and no caller has to carry the number between the two.

Source

pub const fn is_done(&self) -> bool

Whether the read is complete, so no further chunk is owed.

This is the loop condition: a cursor becomes done on the message that does not carry MoreChunkedMessages.

Trait Implementations§

Source§

impl Clone for ReadCursor

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ReadCursor

Source§

impl Debug for ReadCursor

Source§

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

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

impl Default for ReadCursor

Source§

fn default() -> Self

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

impl Eq for ReadCursor

Source§

impl PartialEq for ReadCursor

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ReadCursor

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.