pub struct YcdFileUtil;Implementations§
Source§impl YcdFileUtil
impl YcdFileUtil
pub fn get_header_size<P: AsRef<Path>>(file_name: P) -> Result<i32>
pub fn get_ycd_header<P: AsRef<Path>>( file_name: P, ) -> Result<HashMap<YcdHeaderInfoElem, String>>
Sourcepub fn read_digits<P: AsRef<Path>>(
files: &[P],
one_based_start_position: usize,
length: usize,
) -> Result<String>
pub fn read_digits<P: AsRef<Path>>( files: &[P], one_based_start_position: usize, length: usize, ) -> Result<String>
Read exactly length decimal digits of Pi starting at 1-based position
one_based_start_position from the concatenation of the given YCD files.
§Arguments
files— An ordered, contiguous slice of YCD file paths (BlockID order). The first file need not have BlockID 0; absolute positions are derived from each file’s header.one_based_start_position— 1-based index of the first digit to return. Position 1 is the first decimal digit (the digit immediately after “3.”). The integer part, sign, and decimal point are never included.length— Number of digits to return. The result string is exactlylengthbytes of ASCII digits.
§Returns
A String containing exactly length ASCII decimal digits on success.
§Errors
| Condition | io::ErrorKind |
|---|---|
| Empty file list, position 0, or length 0 | InvalidInput |
| Start position out of range, or end exceeds range | InvalidInput |
| Gap, duplicate, or reversed files in list | InvalidInput |
| Invalid header, non-base-10, or corrupt compressed value | InvalidData |
| Position, offset, or end calculation overflow | InvalidData |
| File does not exist | NotFound |
| Payload truncated within logical range | UnexpectedEof |
| Output string pre-allocation failure | Other |
§Notes
- Files with
TotalDigits == 0are treated as having exactlyBlocksizedigits. A “shortened” final file (where the actual payload is smaller thanBlocksize) cannot be detected via the header alone; payload truncation within the logical range is reported asUnexpectedEof. - The entire file list is validated before any I/O on the payload begins.
- Only the compressed blocks that cover the requested range are decoded; no byte before the target block is read.
- A large
lengthrequires the same amount of heap memory for the result.
Auto Trait Implementations§
impl Freeze for YcdFileUtil
impl RefUnwindSafe for YcdFileUtil
impl Send for YcdFileUtil
impl Sync for YcdFileUtil
impl Unpin for YcdFileUtil
impl UnsafeUnpin for YcdFileUtil
impl UnwindSafe for YcdFileUtil
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