SegBuffer

Struct SegBuffer 

Source
pub struct SegBuffer { /* private fields */ }
Expand description

A segmented buffer that holds data in multiple segments.

The Buffer struct represents a buffer that is divided into multiple segments. It contains the LineIndex and the internal representation of the segments.

Implementations§

Source§

impl SegBuffer

Source

pub fn read_file( file: File, seg_count: NonZeroUsize, complete: bool, ) -> Result<Self>

Source

pub fn read_stream(stream: BoxedStream, complete: bool) -> Result<Self>

Source

pub fn line_count(&self) -> usize

Return the line count of this SegBuffer.

Source

pub fn index(&self) -> &LineIndex

Return the LineIndex of this SegBuffer.

Source

pub fn get_bytes(&self, line_number: usize) -> Option<SegBytes>

Source

pub fn get_line(&self, line_number: usize) -> Option<SegStr>

Retrieves a line of text from the buffer based on the given line number.

§Panics

This function will panic if the line_number is greater than the total number of lines in the buffer’s index.

§Returns

The line of text as a SegStr object.

Source

pub fn segment_iter(&self) -> Result<ContiguousSegmentIterator>

Source

pub fn all_line_matches(&self) -> LineSet

Source

pub fn write_to_file<W>( &mut self, output: &mut W, lines: &LineSet, ) -> Result<()>
where W: Write,

Source

pub fn write_to_string( &mut self, output: &mut String, lines: &LineSet, ) -> 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.