Struct s4lib::data::line::LinePart

source ·
pub struct LinePart {
    pub blockp: BlockP,
    pub blocki_beg: BlockIndex,
    pub blocki_end: BlockIndex,
    pub blocksz: BlockSz,
    /* private fields */
}
Expand description

A LinePart is some or all of a Line within a Block. The purpose of a LinePart is to help track a slice into a Block.

A Line can span more than one Block. A LinePart tracks the line data residing in one Block. One LinePart to one Block.

One or more LineParts are required for a Line.

A LinePart is essentially a slice with some extra “bells & whistles”.

Fields§

§blockp: BlockP

The Block pointer.

§blocki_beg: BlockIndex

Index into the blockp, index at beginning used as-is in slice notation (inclusive).

§blocki_end: BlockIndex

Index into the blockp, index at one after ending '\n' (may refer to one past end of Block) used as-is in slice notation (exclusive).

§blocksz: BlockSz

The file-designated BlockSz, not necessarily the len() of the Block at blockp.

Implementations§

source§

impl LinePart

source

pub fn new( blockp: BlockP, blocki_beg: BlockIndex, blocki_end: BlockIndex, fileoffset: FileOffset, blockoffset: BlockOffset, blocksz: BlockSz ) -> LinePart

Create a new LinePart.

Remember that blocki_end points to one byte past because it used directly in byte array slice notation (exclusive). i.e. (*blockp)[blocki_beg‥blocki_end]

source

pub fn len(&self) -> usize

Length of LinePart starting at index blocki_beg in bytes.

source

pub fn is_empty(&self) -> bool

Clippy recommends fn is_empty since there is a len().

source

pub fn fileoffset_begin(&self) -> FileOffset

FileOffset at beginning of the LinePart (inclusive).

source

pub fn fileoffset_end(&self) -> FileOffset

FileOffset at one byte past ending of the LinePart (exclusive).

source

pub fn blockoffset(&self) -> BlockOffset

BlockOffset of underlying Block to which blockp points.

source

pub fn as_slice(&self) -> &[u8]

Return this linepart as a slice.

source

pub fn count_bytes(&self) -> Count

Count of bytes of this LinePart.

XXX: count_bytes and len is overlapping and confusing.

source

pub fn contains(self: &LinePart, byte_: &u8) -> bool

Does the LinePart contain the byte_?

source

pub fn block_boxptr(&self) -> Box<&[u8]>

Return Box pointer to slice of bytes that make up this LinePart.

source

pub fn block_boxptr_a(&self, a: &LineIndex) -> Box<&[u8]>

Return Box pointer to slice of bytes in this LinePart from a (inclusive) to end.

source

pub fn block_boxptr_b(&self, b: &LineIndex) -> Box<&[u8]>

Return Box pointer to slice of bytes in this LinePart from beginning to b (exclusive).

source

pub fn block_boxptr_ab(&self, a: &LineIndex, b: &LineIndex) -> Box<&[u8]>

Return Box pointer to slice of bytes in this LinePart from a (inclusive) to b (exclusive).

Trait Implementations§

source§

impl Debug for LinePart

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

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.