Expand description
§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:
StreamReaderreads a btrfs send stream from anyimpl Read, validates the stream header (magic, protocol version 1-3), and yieldsStreamCommandvalues with CRC32C integrity checks on every command.StreamCommandis an enum covering all v1, v2, and v3 command types (subvol, snapshot, write, clone, encoded write, fallocate, enable verity, and so on).Timespecrepresents 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.
Structs§
- Receive
Context - Applies a parsed btrfs send stream to a mounted btrfs filesystem.
- Stream
Reader - Reads and parses a btrfs send stream.
- Stream
Writer - TLV-framed encoder for the btrfs send stream. Construct with
StreamWriter::new(writes the stream header), then callStreamWriter::write_commandfor each command. Drop or callStreamWriter::finishto release the inner writer. - Timespec
- A timestamp from the send stream (sec + nsec).
Enums§
- Stream
Command - A parsed command from the send stream.
- Stream
Error - Errors that can occur while parsing a btrfs send stream.