pub struct CreationSource {
pub path: PathBuf,
pub par2_name: String,
pub file_id: FileId,
pub file_length: u64,
pub hash_full: [u8; 16],
pub hash_16k: [u8; 16],
pub slice_checksums: Vec<SliceChecksum>,
}Expand description
A validated explicit source file and the metadata needed by critical PAR2 packets.
§What a planned source has, and what only a created one has
Planning needs a file’s identity — path, PAR2 name, length, the 16 KiB
digest, the FileId derived from them, and how many slices the file
occupies. It does not need the file’s contents: hash_full and the
per-slice checksums are read by exactly one place, the FileDesc and IFSC
bodies in output.rs, and those are only written when outputs are.
Planning fills only the identity, leaving hash_full zero
and one zeroed SliceChecksum per slice — correctly sized, so every
quantity derived from a source (packet lengths, the memory plan, the
staged packet layout) is already final at planning time — and creation
fills the content hashes from the encoder’s input feed where possible,
avoiding a separate hashing pass. Other paths read the source to compute
the hashes before writing the final packets.
A source held by a Par2CreatePlan
therefore carries placeholder content hashes; the sources handed to
packet building never do.
Fields§
§path: PathBufCanonical path read during creation.
par2_name: StringSafe path recorded in PAR2 packets, using / separators.
file_id: FileIdPAR2 file identifier.
file_length: u64Source length in bytes.
hash_full: [u8; 16]MD5 of the complete source file. Zero until creation fills it; see the type’s note on planned versus created sources.
hash_16k: [u8; 16]MD5 of the first 16KiB, or the complete file when shorter.
slice_checksums: Vec<SliceChecksum>Zero-padded per-slice CRC32 and MD5 pairs. One entry per slice from planning onward; the entries are zero until creation fills them.
Implementations§
Source§impl CreationSource
impl CreationSource
Sourcepub fn slice_count(&self) -> u32
pub fn slice_count(&self) -> u32
Number of source slices represented by this source.
Trait Implementations§
Source§impl Clone for CreationSource
impl Clone for CreationSource
Source§fn clone(&self) -> CreationSource
fn clone(&self) -> CreationSource
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CreationSource
impl Debug for CreationSource
impl Eq for CreationSource
Source§impl PartialEq for CreationSource
impl PartialEq for CreationSource
impl StructuralPartialEq for CreationSource
Auto Trait Implementations§
impl Freeze for CreationSource
impl RefUnwindSafe for CreationSource
impl Send for CreationSource
impl Sync for CreationSource
impl Unpin for CreationSource
impl UnsafeUnpin for CreationSource
impl UnwindSafe for CreationSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more