Skip to main content

YcdFileUtil

Struct YcdFileUtil 

Source
pub struct YcdFileUtil;

Implementations§

Source§

impl YcdFileUtil

Source

pub fn get_header_size<P: AsRef<Path>>(file_name: P) -> Result<i32>

Source

pub fn get_ycd_header<P: AsRef<Path>>( file_name: P, ) -> Result<HashMap<YcdHeaderInfoElem, String>>

Source

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 exactly length bytes of ASCII digits.
§Returns

A String containing exactly length ASCII decimal digits on success.

§Errors
Conditionio::ErrorKind
Empty file list, position 0, or length 0InvalidInput
Start position out of range, or end exceeds rangeInvalidInput
Gap, duplicate, or reversed files in listInvalidInput
Invalid header, non-base-10, or corrupt compressed valueInvalidData
Position, offset, or end calculation overflowInvalidData
File does not existNotFound
Payload truncated within logical rangeUnexpectedEof
Output string pre-allocation failureOther
§Notes
  • Files with TotalDigits == 0 are treated as having exactly Blocksize digits. A “shortened” final file (where the actual payload is smaller than Blocksize) cannot be detected via the header alone; payload truncation within the logical range is reported as UnexpectedEof.
  • 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 length requires the same amount of heap memory for the result.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.