Skip to main content

FileInfo

Struct FileInfo 

Source
pub struct FileInfo {
    pub lines: Vec<String>,
    pub total_lines: usize,
    pub total_lines_exact: bool,
    pub total_bytes: usize,
    pub truncated: bool,
    pub truncated_by_lines: bool,
    pub truncated_by_bytes: bool,
    pub language: Option<String>,
    pub encoding: String,
    pub syntax_errors: Vec<String>,
    pub compression_ratio: Option<f64>,
}
Expand description

Information about a processed file

Fields§

§lines: Vec<String>

The processed lines of the file

§total_lines: usize

Total number of lines in the original file

§total_lines_exact: bool

Whether total_lines reflects the entire file

§total_bytes: usize

Total number of bytes in the original file

§truncated: bool

Whether the file was truncated during processing

§truncated_by_lines: bool

Whether truncation was due to line limit

§truncated_by_bytes: bool

Whether truncation was due to byte limit

§language: Option<String>

Detected or specified language

§encoding: String

Detected encoding of the file

§syntax_errors: Vec<String>

Syntax errors encountered during processing

§compression_ratio: Option<f64>

Ratio of original line count to stripped line count (set when strip_comments or strip_blank_lines is active)

Implementations§

Source§

impl FileInfo

Source

pub fn new() -> Self

Create a new FileInfo instance

Source

pub const fn with_metadata( total_lines: usize, total_bytes: usize, language: Option<String>, encoding: String, ) -> Self

Create a FileInfo with basic metadata

Source

pub fn with_lines(self, lines: Vec<String>) -> Self

Set the processed lines

Source

pub const fn with_truncation( self, truncated: bool, by_lines: bool, by_bytes: bool, ) -> Self

Set truncation information

Source

pub fn add_syntax_error(&mut self, error: String)

Add a syntax error

Source

pub const fn with_compression_ratio(self, ratio: Option<f64>) -> Self

Set compression ratio (original lines / stripped lines)

Source

pub const fn with_total_lines_exact(self, exact: bool) -> Self

Mark whether total_lines is exact

Source

pub fn is_success(&self) -> bool

Check if the file was processed successfully

Source

pub fn processed_lines(&self) -> usize

Get the number of processed lines

Source

pub fn processing_ratio(&self) -> f64

Get the processing ratio (processed lines / total lines)

Source

pub fn truncation_reason(&self) -> Option<String>

Get truncation reason as a human-readable string

Source

pub fn get_stats_summary(&self) -> ProcessingStats

Get a summary of processing statistics

Trait Implementations§

Source§

impl Clone for FileInfo

Source§

fn clone(&self) -> FileInfo

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FileInfo

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for FileInfo

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for FileInfo

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for FileInfo

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.