Skip to main content

DeferBuf

Struct DeferBuf 

Source
pub struct DeferBuf {
    buf: [u8; 16384],
    head: usize,
    len: usize,
    dropped: u32,
}

Fields§

§buf: [u8; 16384]§head: usize

最も古いバイトの位置。

§len: usize

貯まっているバイト数。

§dropped: u32

Implementations§

Source§

impl DeferBuf

Source

pub const fn new() -> Self

Source

pub fn push(&mut self, line: &[u8]) -> bool

1 行(改行込み)を後ろへ足す。入り切らなければ足さずに捨てた数を 1 増やし、false を返す。 行の一部だけを入れることはしない(行が途中で切れて出ることはない)。

Source

pub fn note_dropped(&mut self)

捨てた行の数を 1 件ぶん数える(入れ物の錠が取れなかったときなど、呼ぶ側で捨てた分)。

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn take_dropped(&mut self) -> u32

捨てた行の数を読んで 0 へ戻す。

Source

fn byte_at(&self, i: usize) -> u8

先頭から i バイト目(貯まっている範囲の中)。

Source

pub fn take_lines(&mut self, out: &mut [u8]) -> usize

先頭から、out に入るだけの行(改行まで)を写して取り除き、写したバイト数を返す。 先頭の 1 行が out より長いときは、out に入るだけ(UTF-8 の文字の途中では切らない)を写す。

Trait Implementations§

Source§

impl Default for DeferBuf

Source§

fn default() -> Self

Returns the “default value” for a type. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.