Skip to main content

Core Types Reference

This page documents every public type exported by vpt_rs. All types live in the vpt_rs::types module and are re-exported from the crate root.

VolumeRef​

A stable identifier for a live volume, filesystem, dataset, or provider-specific source. The id string is interpreted differently by each backend.

Backendid formatExample
BtrfsAbsolute subvolume path"/mnt/data/subvol"
LVM/dev/<vg>/<lv> path"/dev/vg0/data"
ZFSDataset name or mount path"tank/data"
WindowsDrive letter or volume GUID path"C:"
use vpt_rs::VolumeRef;

// Construct from a string literal
let vol = VolumeRef::new("/mnt/data/subvol");

// From<String> is implemented, so the ? operator and .into() both work
let id = String::from("/dev/vg0/data");
let vol2: VolumeRef = id.into();

// Display prints the raw id
println!("volume: {vol}"); // "volume: /mnt/data/subvol"

Capability​

An enum listing every feature a backend might support. Used by Backend::capabilities() and Backend::supports().

use vpt_rs::Capability;

let caps = vec![
Capability::CrashConsistentSnapshot,
Capability::BlockLevelBackup,
Capability::IncrementalSend,
];
Variantas_str()Description
CrashConsistentSnapshot"crash_consistent_snapshot"Filesystem-consistent snapshot (no app quiescing)
ApplicationConsistentSnapshot"application_consistent_snapshot"App-quiesced snapshot (VSS writers on Windows)
WritableSnapshotMount"writable_snapshot_mount"Can mount snapshots read-write
ReadOnlySnapshotMount"read_only_snapshot_mount"Can mount snapshots read-only
BlockLevelBackup"block_level_backup"Supports dd-style block copy backup
BlockLevelRestore"block_level_restore"Supports dd-style block copy restore
IncrementalSend"incremental_send"Supports incremental send/receive streams
DirectDeviceAccess"direct_device_access"Can read/write raw block devices

SnapshotKind​

Consistency intent for a snapshot operation.

use vpt_rs::SnapshotKind;

let kind: SnapshotKind = "crash".parse().unwrap();
assert_eq!(kind, SnapshotKind::CrashConsistent);

let kind2: SnapshotKind = "application".parse().unwrap();
assert_eq!(kind2, SnapshotKind::ApplicationConsistent);
VariantAccepted parse stringsMeaning
CrashConsistent"crash", "crash-consistent"Like pulling the power plug; filesystem-safe
ApplicationConsistent"app", "application", "application-consistent"Coordinates with VSS writers to flush buffers

SnapshotRequest​

A provider-neutral request to create a snapshot.

use vpt_rs::{SnapshotRequest, SnapshotKind, VolumeRef};

let request = SnapshotRequest {
source: VolumeRef::new("/mnt/data/subvol"),
kind: SnapshotKind::CrashConsistent,
label: Some("nightly".to_string()),
read_only: true,
};
FieldTypeDescription
sourceVolumeRefThe volume to snapshot
kindSnapshotKindConsistency level
labelOption<String>Optional human-readable label (sanitized on use)
read_onlyboolWhether the snapshot should be read-only

SnapshotHandle​

A concrete snapshot identifier returned after creation. The id format varies by provider (e.g. absolute path for Btrfs, /dev/<vg>/<snap_lv> for LVM, dataset@name for ZFS, {GUID} for VSS).

use vpt_rs::SnapshotHandle;

let handle = SnapshotHandle {
id: "/mnt/data/snapshots/nightly-20260607".to_string(),
source: None,
};
FieldTypeDescription
idStringProvider-specific snapshot identifier
sourceOption<VolumeRef>The originating volume, if known

SnapshotRef​

A reference to an existing snapshot, used in backup/restore planning. Separate from SnapshotHandle so plans can refer to snapshots created outside the current process.

use vpt_rs::{SnapshotRef, VolumeRef};

let snap_ref = SnapshotRef::new("tank/data@backup-20260601")
.with_origin(VolumeRef::new("tank/data"));
FieldTypeDescription
idStringProvider-specific snapshot identifier
originOption<VolumeRef>The volume this snapshot belongs to

SnapshotInfo​

Provider-reported metadata about a snapshot.

use vpt_rs::{SnapshotInfo, SnapshotHandle};
use std::path::PathBuf;

let info = SnapshotInfo {
handle: SnapshotHandle { id: "vg0-data-snap".to_string(), source: None },
backend: "linux-lvm",
path_hint: Some(PathBuf::from("/dev/vg0/data-snap")),
read_only: true,
};
FieldTypeDescription
handleSnapshotHandleThe snapshot handle
backend&'static strBackend name that created it
path_hintOption<PathBuf>Suggested filesystem path, if applicable
read_onlyboolWhether the snapshot is read-only

BackupTarget​

Destination for a backup operation.

use vpt_rs::BackupTarget;
use std::path::PathBuf;

let img = BackupTarget::ImageFile(PathBuf::from("/tmp/backup.img"));
let dev = BackupTarget::Device(PathBuf::from("/dev/sdb1"));
VariantInnerDescription
ImageFilePathBufWrite backup to a regular file
DevicePathBufWrite backup to a raw block device

BackupSource​

Source for a backup -- either a live volume or an explicit snapshot.

use vpt_rs::{BackupSource, VolumeRef, SnapshotRef};

let from_vol = BackupSource::Volume(VolumeRef::new("/dev/vg0/data"));
let from_snap = BackupSource::Snapshot(SnapshotRef::new("tank@daily"));

SnapshotPolicy​

Controls whether the provider should create a temporary snapshot before backing up.

use vpt_rs::{SnapshotPolicy, SnapshotKind};

// No automatic snapshot
let disabled = SnapshotPolicy::disabled();

// Create a temporary crash-consistent snapshot
let temp = SnapshotPolicy::temporary(
SnapshotKind::CrashConsistent,
Some("backup".to_string()),
true,
);
VariantFieldsMeaning
Disabled(none)Use the source as-is
Temporarykind, label: Option<String>, read_onlyCreate a temp snapshot, use it, clean up

BackupPlan​

A provider-neutral plan that describes what to back up, where, and how.

use vpt_rs::{BackupPlan, BackupSource, BackupTarget, SnapshotPolicy, SnapshotKind, VolumeRef};
use std::path::PathBuf;

let plan = BackupPlan {
source: BackupSource::Volume(VolumeRef::new("/dev/vg0/data")),
target: BackupTarget::ImageFile(PathBuf::from("/tmp/backup.img")),
snapshot_policy: SnapshotPolicy::temporary(
SnapshotKind::CrashConsistent, Some("backup".to_string()), true,
),
parent_snapshot: None,
block_size: None,
};
FieldTypeDescription
sourceBackupSourceLive volume or explicit snapshot
targetBackupTargetImage file or block device
snapshot_policySnapshotPolicyWhether to create a temp snapshot first
parent_snapshotOption<SnapshotRef>Base snapshot for incremental send
block_sizeOption<usize>I/O chunk size; None = provider default (4 MiB)

RestorePlan​

A provider-neutral plan for restoring from a backup.

use vpt_rs::{RestorePlan, BackupTarget, VolumeRef};
use std::path::PathBuf;

let plan = RestorePlan {
source: BackupTarget::ImageFile(PathBuf::from("/tmp/backup.img")),
destination: VolumeRef::new("/dev/vg0/restored"),
force: true,
base_snapshot: None,
block_size: None,
};
FieldTypeDescription
sourceBackupTargetImage file or device to restore from
destinationVolumeRefTarget volume
forceboolRequired for destructive backends (LVM, VSS)
base_snapshotOption<SnapshotRef>Base for incremental restore workflows
block_sizeOption<usize>I/O chunk size; None = provider default (4 MiB)

MountMode, MountRequest, MountHandle​

Types for snapshot mounting.

use vpt_rs::{MountMode, MountRequest, MountHandle, SnapshotHandle};
use std::path::PathBuf;

let request = MountRequest {
snapshot: SnapshotHandle { id: "/dev/vg0/snap".to_string(), source: None },
mode: MountMode::ReadOnly,
target: Some(PathBuf::from("/mnt/browse")),
};

// After a successful mount:
let handle = MountHandle {
id: "mount-1".to_string(),
mount_point: PathBuf::from("/mnt/browse"),
};
TypeKey fieldsPurpose
MountModeReadOnly, ReadWriteAccess level for the mount
MountRequestsnapshot, mode, targetWhat to mount and how
MountHandleid, mount_pointResult of a successful mount

sanitize_snapshot_label()​

Sanitizes a user-provided label into a safe snapshot name component. Characters outside [a-zA-Z0-9\-_.+:] are replaced with -. Returns "snapshot" if the result would be empty or all dashes.

use vpt_rs::sanitize_snapshot_label;

assert_eq!(sanitize_snapshot_label("nightly backup"), "nightly-backup");
assert_eq!(sanitize_snapshot_label("2026/06/07"), "2026-06-07");
assert_eq!(sanitize_snapshot_label("---"), "snapshot");
assert_eq!(sanitize_snapshot_label("valid_name.test"), "valid_name.test");

Type Relationship Diagram​

The following diagram shows how the core types relate to each other.