pub struct FixedStructReader { /* private fields */ }
Expand description

A specialized reader that uses BlockReader to read FixedStruct entries in a file.

The FixedStructReader converts \[u8\] to FixedStruct in buffer_to_fixedstructptr.

§Summary of operation

A FixedStructReader first deteremines the FixedStructType of the file in preprocess_fixedstructtype. Then it scans all time values in each entry to determine the order to process the entries in preprocess_timevalues. This implies the blockreader must read the entire file into memory. So far, “in the wild” user accounting records are only a few kilobytes at most. So reading the entire file into memory should not put too much strain on memory usage. The processing of time values is done first and for the entire file because records may not be stored in chronological order. Then the caller makes repeated calls to process_entry_at which processes the FixedStructs found in the file.

0x00 byte and 0xFF byte fixedstructs are considered a null entry and ignored.

XXX: not a rust “Reader”; does not implement trait Read.

Implementations§

source§

impl FixedStructReader

Implement the FixedStructReader.

source

pub fn new( path: FPath, filetype: FileType, blocksz: BlockSz, tz_offset: FixedOffset, dt_filter_after: DateTimeLOpt, dt_filter_before: DateTimeLOpt ) -> ResultFixedStructReaderNewError

Create a new FixedStructReader.

NOTE: this new() calls BlockerReader.read_block, dissimilar from other *Readers::new() which try to avoid calls to read_block. This means the reading may return Done (like if the file is empty) and Done must be reflected in the return value of new. Hence this function has a specialized return value.

source

pub const fn blocksz(&self) -> BlockSz

source

pub const fn filesz(&self) -> FileSz

source

pub const fn filetype(&self) -> FileType

source

pub const fn path(&self) -> &FPath

source

pub const fn mimeguess(&self) -> MimeGuess

source

pub fn mtime(&self) -> SystemTime

source

pub fn count_entries_processed(&self) -> Count

Count of FixedStructs processed by this FixedStructReader (i.e. self.entries_processed).

source

pub fn entries_stored_highest(&self) -> usize

High watermark” of FixedStruct stored in self.cache_entries.

source

pub const fn block_offset_at_file_offset( &self, fileoffset: FileOffset ) -> BlockOffset

source

pub const fn file_offset_at_block_offset( &self, blockoffset: BlockOffset ) -> FileOffset

source

pub const fn file_offset_at_block_offset_index( &self, blockoffset: BlockOffset, blockindex: BlockIndex ) -> FileOffset

source

pub const fn block_index_at_file_offset( &self, fileoffset: FileOffset ) -> BlockIndex

source

pub const fn count_blocks(&self) -> Count

source

pub const fn blockoffset_last(&self) -> BlockOffset

source

pub const fn fileoffset_last(&self) -> FileOffset

source

pub const fn is_fileoffset_last(&self, fileoffset: FileOffset) -> bool

Is the passed FileOffset the last byte of the file?

source

pub fn is_last(&self, fixedstruct: &FixedStruct) -> bool

Is the passed FixedStruct the last of the file?

source

pub const fn fileoffset_to_fixedstructoffset( &self, fileoffset: FileOffset ) -> FileOffset

Return the FileOffset that is adjusted to the beginning offset of a fixedstruct entry.

source

pub fn fileoffset_first(&self) -> Option<FileOffset>

Return the first file offset from self.map_tvpair_fo for the first entry as sorted by tv_pair_type (datetime); i.e. the earliest entry. Ties are broken by FileOffset.

source

pub const fn fixedstruct_size(&self) -> usize

The size in bytes of the FixedStruct entries managed by this FixedStructReader.

source

pub const fn fixedstruct_size_fo(&self) -> FileOffset

fixedstruct_size as a FileOffset.

source

pub const fn fixedstruct_type(&self) -> FixedStructType

The FixedStructType of the file.

source

pub fn score_file( blockreader: &mut BlockReader, oneblock: bool, types_to_bonus: HashMap<FixedStructType, Score> ) -> ResultFixedStructReaderScoreFileError

Process entries for the file managed by the BlockReader. Find the entry with the highest “score” as judged by score_fixedstruct.

Returns the highest scored FixedStructType, that highest score, and any processed FixedStruct entries (referenced by a FixedStructDynPtr) in a list.

Each list entry is a tuple of the the entries FileOffset and the FixedStructDynPtr. The entries will presumably be stored in the FixedStructReader’s cache_entries.

source

pub fn process_entry_at( &mut self, fo: FileOffset, buffer: &mut [u8] ) -> ResultS3FixedStructFind

Process the data at FileOffset fo. Transform it into a FixedStruct using FixedStruct::new. But before that, check private self.cache_entries in case the data at the fileoffset was already processed (transformed) during FixedStructReader::new.

Let the caller pass a buffer to avoid this function having allocate.

This function does the bulk of file processing after the FixedStructReader has been initialized during FixedStructReader::new.

source

pub fn entry_dt_after_or_before( entry: &FixedStruct, dt_filter: &DateTimeLOpt ) -> Result_Filter_DateTime1

Wrapper function for call to datetime::dt_after_or_before using the FixedStruct::dt of the entry.

source

pub fn entry_pass_filters( entry: &FixedStruct, dt_filter_after: &DateTimeLOpt, dt_filter_before: &DateTimeLOpt ) -> Result_Filter_DateTime2

Wrapper function for call to datetime::dt_pass_filters using the FixedStruct::dt of the entry.

source

pub fn summary(&self) -> SummaryFixedStructReader

Return an up-to-date SummaryFixedStructReader instance for this FixedStructReader.

source

pub fn summary_complete(&self) -> Summary

Return an up-to-date Summary instance for this FixedStructReader.

Trait Implementations§

source§

impl Debug for FixedStructReader

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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>,

§

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.