mod container;
mod node;
mod object;
mod omap;
mod record;
mod snapshot;
mod space;
mod volume;
pub use container::{
BlockRange, CHECKPOINT_AREA_IS_TREE, CONTAINER_MAGIC, COUNTERS, CheckpointAreas,
ContainerSuperblock, MAX_BLOCK_SIZE, MAX_VOLUMES, MIN_BLOCK_SIZE,
incompat as container_incompat,
};
pub use node::{
CHILD_POINTER_SIZE, EntrySizes, NO_VALUE, NODE_DATA_START, Node, NodeFault, NodeHeader,
TREE_ALLOW_GHOSTS, TREE_EPHEMERAL, TREE_HASHED, TREE_INFO_SIZE, TREE_KV_NONALIGNED,
TREE_NO_HEADER, TREE_PHYSICAL, TREE_SEQUENTIAL_INSERT, TreeInfo, Unused, child_oid, node_flags,
};
pub use object::{ObjectHeader, Storage, checksum, kind, seal, verify};
pub use omap::{
CRYPTO_GENERATION, MAP_CRYPTO_CHANGING, MAP_VALUE_DELETED, MapKey, MapValue, ObjectMap,
};
pub use record::{
BSD_COMPRESSED, DECMPFS_XATTR, DataStream, ENTRY_TYPE_MASK, EXTENT_LENGTH_MASK, EntryKey,
EntryValue, ExtendedField, FileExtent, ID_MASK, INTERNAL_BEING_TRUNCATED, INTERNAL_COMPRESSED,
INTERNAL_EVER_CLONED, INTERNAL_WITH_RESOURCE_FORK, INTERNAL_WITH_SECURITY_ATTRIBUTE,
INTERNAL_WITHOUT_RESOURCE_FORK, InodeValue, KIND_SHIFT, KeyHeader, PHYSICAL_LENGTH_MASK,
PhysicalExtent, RESOURCE_FORK_XATTR, SECURITY_XATTR, SIBLING_ID_FIELD, SYMLINK_XATTR,
SiblingLink, XattrValue, extended_field_blob, extended_fields, field, inode_field,
inode_number, key_u64, record_kind, sibling_map_record, split_device, xattr_flags, xattr_key,
xattr_key_size, xattr_name,
};
pub use snapshot::{SNAPSHOT_NAME_ID, SnapshotExtension, SnapshotMeta, snapshot_name_record};
pub use space::{
CHECKPOINT_MAP_LAST, CI_COUNT_MASK, CheckpointMap, CheckpointMapping, ChunkInfo, ChunkList,
FreeQueue, FreeQueueKey, REAPER_ALWAYS, REAPER_CONTINUE, ReapList, Reaper, SpaceDevice,
SpaceManager,
};
pub use volume::{
MODIFIED_BY_ENTRIES, ModifiedBy, VOLUME_MAGIC, VOLUME_NAME_LEN, VolumeSuperblock,
incompat as volume_incompat, role_name, volume_flags,
};
#[derive(Clone, Copy, PartialEq, Eq, Debug, thiserror::Error)]
#[non_exhaustive]
pub enum ParseError {
#[error("{structure}: need {need} bytes, got {got}")]
#[non_exhaustive]
TooShort {
structure: &'static str,
need: usize,
got: usize,
},
#[error("{structure}: not an APFS signature: {found:02x?}")]
#[non_exhaustive]
BadMagic {
structure: &'static str,
found: [u8; 4],
},
#[error("{structure}: the stored name does not end in its terminator")]
#[non_exhaustive]
Unterminated {
structure: &'static str,
},
}
impl ParseError {
fn need(structure: &'static str, need: usize, buf: &[u8]) -> Result<(), Self> {
if buf.len() < need {
return Err(Self::TooShort {
structure,
need,
got: buf.len(),
});
}
Ok(())
}
}