Reader

Struct Reader 

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

A Reader implements the io.Reader, io.ReaderAt, io.ByteReader, io.ByteScanner, io.RuneReader, io.RuneScanner, io.Seeker, and io.WriterTo interfaces by reading from a string. The zero value for Reader operates like a Reader of an empty string.

zh-cn

Implementations§

Source§

impl Reader

Source

pub fn new(s: &str) -> Reader

new returns a new Reader reading from s. more efficient and read-only.

zh-cn NewReader创建一个从s读取数据的Reader。更有效率,且为只读的。
Source

pub fn Len(&self) -> int

Len returns the number of bytes of the unread portion of the string.

zh-cn Len返回self包含的字符串还没有被读取的部分。
Source

pub fn Reset(&mut self, s: &str)

Reset resets the Reader to be reading from s.

zh-cn 重置将Reader重置为从s读取。
Source

pub fn Size(&self) -> int64

Size returns the original length of the underlying string. Size is the number of bytes available for reading via ReadAt. The returned value is always the same and is not affected by calls to any other method.

zh-cn Size返回基础字符串的原始长度。Size是可通过ReadAt读取的字节数。返回的值始终相同,并且不受对任何其他方法的调用的影响。

Trait Implementations§

Source§

impl ByteReader for Reader

Source§

fn ReadByte(&mut self) -> Result<byte, Error>

Source§

impl ByteScanner for Reader

Source§

fn UnreadByte(&mut self) -> Result<(), Error>

Source§

impl Clone for Reader

Source§

fn clone(&self) -> Reader

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Reader

Source§

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

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

impl Default for Reader

Source§

fn default() -> Reader

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

impl PartialEq for Reader

Source§

fn eq(&self, other: &Reader) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Reader

Source§

fn partial_cmp(&self, other: &Reader) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Reader for Reader

Source§

fn Read(&mut self, b: Vec<byte>) -> Result<int, Error>

Read implements the io.Reader interface.

zh-cn
Source§

impl ReaderAt for Reader

Source§

fn ReadAt(&mut self, b: Vec<byte>, off: int64) -> Result<int, Error>

Source§

impl RuneReader for Reader

Source§

fn ReadRune(&mut self) -> Result<(rune, int), Error>

Source§

impl Seeker for Reader

Source§

fn Seek(&mut self, offset: int64, whence: Whence) -> int64

Source§

impl WriterTo for Reader

Source§

fn WriteTo(&mut self, w: Box<dyn Writer>) -> Result<int64, Error>

Source§

impl StructuralPartialEq for Reader

Auto Trait Implementations§

§

impl Freeze for Reader

§

impl RefUnwindSafe for Reader

§

impl Send for Reader

§

impl Sync for Reader

§

impl Unpin for Reader

§

impl UnwindSafe for Reader

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