diff-in-place 0.1.2

A no_std, zero-copy, in-place diff trait for constant sized arrays
Documentation
  • Coverage
  • 50%
    2 out of 4 items documented2 out of 3 items with examples
  • Size
  • Source code size: 11.97 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 294.94 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • botanica-consulting/diff-in-place
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • 0xa10

diff-in-place

A lightweight, Rust idiomatic trait for comparing two constant size arrays in-place and with no copies. Each non-equal run inside the two arrays results in the callback being invoked with the starting index and the different bytes.

This is useful for embedded environments, for instance when updating the state of integrated chip over a peripheral bus such as I2c/SMBus.

This crate is suitable for usage in no_std targets.

Example

use diff_in_place::DiffInPlace;

// In this scenario you want to update the state on the chip without sending all 7 bytes
let state_on_chip = [0, 0, 1, 1, 1, 1, 1];
let mut new_state = state.clone()

new_state[6] = 0;

state_on_chip.diff_in_place(new_state, |i, data| {
    // i = 6
    // data = [0,]
    peripheral.write_at(i, data);
});

Disclaimer: This library is not an official product, use freely at your own risk.