#infinity #no-alloc #coap #vector #logging #view #data #infinite

no-std windowed-infinity

A data structure representing an infinite sequentially writable u8 vector of which a small view has writes to it preserved. This is primarily useful when implementing CoAP block-wise transfers, and also convenient for logging on constrained devices.

5 releases

0.1.4 Feb 1, 2023
0.1.3 Jan 25, 2023
0.1.2 Jan 3, 2023
0.1.1 Oct 22, 2020
0.1.0 Jan 22, 2019

#89 in No standard library

Download history 186/week @ 2022-11-27 195/week @ 2022-12-04 497/week @ 2022-12-11 187/week @ 2022-12-18 52/week @ 2022-12-25 133/week @ 2023-01-01 132/week @ 2023-01-08 248/week @ 2023-01-15 449/week @ 2023-01-22 236/week @ 2023-01-29 168/week @ 2023-02-05 237/week @ 2023-02-12 379/week @ 2023-02-19 152/week @ 2023-02-26 153/week @ 2023-03-05 118/week @ 2023-03-12

818 downloads per month
Used in 8 crates (2 directly)

MIT/Apache

24KB
401 lines

This crate provides the [WindowedInfinity] struct and implementations of various traits to write to it.

Its primary is to wrap a small buffer such that writes to it advance a cursor over a larger imaginary buffer, only persisting writes to the small buffer. After the buffer has been processed, a new WindowedInfinity can be set up and the writing process repeated. This is wasteful when the writes are computationally expensive, but convenient when operations only rarely exceed the buffer.

A typical practical example of WindowedInfinity application is the implementation of CoAP block-wise transfer according to RFC7959; a simpler example is available in the demo.rs example.

Features

The set of traits implemented by [WindowedInfinity] depends on the configured cargo features:

  • With the std feature, it implements std::io::Write
  • With the with_serde_cbor feature, it uses serde_cbor's trait unsealing feature to implement its Write trait.
  • Likewise, there are features for ciborium and minicbor. The minicbor version is a bit special in that there is both a with_minicbor / with_minicbor_0_19 feature.
  • Starting at with_minicbor_0_19, features carry a version. This allows users of different minicbor versions to coexist in the same crate, and moreover ensures that the dependencies expressed in the Cargo.toml files to describe the requirements precisely.
  • With the with_embedded_io_0_4 feature, the Write trait of embedded-io is implemented.

Crate size

Compared to the original plan of "doing one thing, and doing that right", this crate has grown a bit, in that it contains trait implementations for several serializers, and extra mechanism for combining the own writer with others (from cryptographic digests or CRCs). Both these are temporary -- once there is a 1.0 version of embedded-io, the Tee will be split out into a dedicated crate (with only compatibility re-exports and constructors / destructors remaining), and once serializers start using the stable embedded-io, no more writer implementations will need to be added.

Dependencies

~320–540KB
~13K SLoC