#byte-stream #chunks #layer #writable #overlay #puts #read

memoverlay

Puts a writable layer of bytes over some byte stream

4 releases

0.1.3 Apr 12, 2024
0.1.2 Jan 2, 2023
0.1.1 Jan 2, 2023
0.1.0 Jan 2, 2023

#3 in #writable

Download history 58/week @ 2024-02-29 108/week @ 2024-03-07 63/week @ 2024-03-14 53/week @ 2024-03-21 89/week @ 2024-03-28 105/week @ 2024-04-04 272/week @ 2024-04-11 60/week @ 2024-04-18 69/week @ 2024-04-25 34/week @ 2024-05-02 49/week @ 2024-05-09 46/week @ 2024-05-16 72/week @ 2024-05-23 63/week @ 2024-05-30 80/week @ 2024-06-06 94/week @ 2024-06-13

317 downloads per month
Used in 4 crates (via nt_hive2)

GPL-3.0 license

25KB
520 lines

memoverlay

Puts a writable layer of bytes over some byte stream

memoverlay

+-----------------+------------+-----------------+-------+----------------------+-------+-----------------+
|    chunk 0      |  chunk 1   |    chunk 2      |   3   |       chunk 4        |   5   |     chunk 6     |
+-----------------+------------+-----------------+-------+----------------------+-------+-----------------+

                               +-----------------+       +----------------------+
                               +-----------------+       +----------------------+
                  +-------------------+                           +---------------------+
                  +-------------------+                           +---------------------+
+---------------------------------------------------------------------------------------------------------+
+---------------------------------------------------------------------------------------------------------+

Usage example

use std::io::{Cursor, Read, Seek, SeekFrom};
use memoverlay::MemOverlay;
use memoverlay::overlay;

let message1 = "hello, world!";
let mut overlay = overlay!(message1.as_bytes());
overlay.add_bytes_at(7, "peter".as_bytes()).unwrap();

let mut message2 = String::new();
let _ = overlay.read_to_string(&mut message2).unwrap();

assert_eq!(message2, "hello, peter!");

License: GPL-3.0

Dependencies

~315–780KB
~18K SLoC