1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! # btrfs-stream: btrfs send stream parser and receive operations
//!
//! This crate handles the btrfs send stream format: a binary TLV protocol
//! used by `btrfs send` / `btrfs receive` to serialize and replay filesystem
//! changes between subvolume snapshots.
//!
//! ## Stream parsing (default, platform-independent)
//!
//! The default feature set provides a zero-copy stream parser that works on
//! any platform:
//!
//! - [`StreamReader`] reads a btrfs send stream from any `impl Read`,
//! validates the stream header (magic, protocol version 1-3), and yields
//! [`StreamCommand`] values with CRC32C integrity checks on every command.
//! - [`StreamCommand`] is an enum covering all v1, v2, and v3 command types
//! (subvol, snapshot, write, clone, encoded write, fallocate, enable
//! verity, and so on).
//! - [`Timespec`] represents timestamps carried in the stream.
//!
//! ## Receive operations (feature `receive`, Linux-only)
//!
//! Enable the `receive` feature to get [`ReceiveContext`], which applies a
//! parsed stream to a mounted btrfs filesystem. It creates subvolumes and
//! snapshots, writes files, clones extents, sets xattrs and permissions, and
//! finalizes received subvolumes with their received UUID. It handles v2
//! encoded writes with automatic decompression fallback (zlib, zstd, lzo)
//! and v3 fs-verity enablement.
//!
//! This feature depends on `btrfs-uapi` for ioctl access and requires
//! `CAP_SYS_ADMIN` on Linux.
// Test code uses literal byte buffers and small cast conversions that
// pedantic clippy flags but that are intentional in unit tests.
pub use ReceiveContext;
pub use StreamWriter;
pub use ;