Crates.io | windowed-infinity |
lib.rs | windowed-infinity |
version | 0.1.7 |
source | src |
created_at | 2019-01-22 23:14:54.61702 |
updated_at | 2024-10-30 13:44:14.918555 |
description | 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. |
homepage | |
repository | https://gitlab.com/chrysn/windowed-infinity |
max_upload_size | |
id | 110096 |
size | 47,268 |
This crate provides the WindowedInfinity struct and implementations of various traits to write to it.
Its primary purpose 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 a WindowedInfinity application is the implementation of CoAP
block-wise transfer according to RFC7959; a simpler
example is available in the demo.rs
example.
The set of traits implemented by WindowedInfinity depends on the configured cargo features:
std
feature, it implements std::io::Write
with_serde_cbor
feature, it uses serde_cbor
’s trait unsealing feature to
implement its Write
trait.with_minicbor
/ with_minicbor_0_19
feature.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_embedded_io_0_4
, _0_6
and _async_0_6
features, the Write trait of
embedded-io
/ -async
is implemented.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.