Crates.io | memoverlay |
lib.rs | memoverlay |
version | 0.1.3 |
source | src |
created_at | 2023-01-02 17:13:55.882762 |
updated_at | 2024-04-12 08:06:36.666756 |
description | Puts a writable layer of bytes over some byte stream |
homepage | |
repository | https://github.com/janstarke/memoverlay |
max_upload_size | |
id | 749530 |
size | 61,879 |
Puts a writable layer of bytes over some byte stream
+-----------------+------------+-----------------+-------+----------------------+-------+-----------------+
| chunk 0 | chunk 1 | chunk 2 | 3 | chunk 4 | 5 | chunk 6 |
+-----------------+------------+-----------------+-------+----------------------+-------+-----------------+
+-----------------+ +----------------------+
+-----------------+ +----------------------+
+-------------------+ +---------------------+
+-------------------+ +---------------------+
+---------------------------------------------------------------------------------------------------------+
+---------------------------------------------------------------------------------------------------------+
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