pub struct AlignmentTracker {
pub position: usize,
pub default_alignment: usize,
}Expand description
Helper struct for tracking alignment during file writing
Fields§
§position: usizeCurrent position in the output stream
default_alignment: usizeDefault alignment to use
Implementations§
Source§impl AlignmentTracker
impl AlignmentTracker
Sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Create a new alignment tracker with GGUF default alignment
Sourcepub fn advance(&mut self, bytes: usize)
pub fn advance(&mut self, bytes: usize)
Advance the position by the given amount, saturating at usize::MAX.
Sourcepub fn checked_advance(&mut self, bytes: usize) -> Option<()>
pub fn checked_advance(&mut self, bytes: usize) -> Option<()>
Advance the position, returning None if it would overflow.
Sourcepub fn calculate_padding(&self) -> usize
pub fn calculate_padding(&self) -> usize
Calculate padding needed for default alignment
Sourcepub fn calculate_padding_for(&self, alignment: usize) -> usize
pub fn calculate_padding_for(&self, alignment: usize) -> usize
Calculate padding needed for specific alignment
Sourcepub fn align_default(&mut self) -> AlignmentInfo
pub fn align_default(&mut self) -> AlignmentInfo
Align to default boundary and return padding info
Sourcepub fn align_to(&mut self, alignment: usize) -> AlignmentInfo
pub fn align_to(&mut self, alignment: usize) -> AlignmentInfo
Align to specific boundary and return padding info
Sourcepub fn current_alignment_info(&self) -> AlignmentInfo
pub fn current_alignment_info(&self) -> AlignmentInfo
Get current alignment info without advancing
Sourcepub fn is_aligned(&self) -> bool
pub fn is_aligned(&self) -> bool
Check if currently aligned to default boundary
Sourcepub fn is_aligned_to(&self, alignment: usize) -> bool
pub fn is_aligned_to(&self, alignment: usize) -> bool
Check if currently aligned to specific boundary
Trait Implementations§
Source§impl Clone for AlignmentTracker
impl Clone for AlignmentTracker
Auto Trait Implementations§
impl Freeze for AlignmentTracker
impl RefUnwindSafe for AlignmentTracker
impl Send for AlignmentTracker
impl Sync for AlignmentTracker
impl Unpin for AlignmentTracker
impl UnsafeUnpin for AlignmentTracker
impl UnwindSafe for AlignmentTracker
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
Mutably borrows from an owned value. Read more