KVReader

Struct KVReader 

Source
pub struct KVReader<'a, S: NorFlash> {
    pub entry: KVEntry,
    /* private fields */
}
Expand description

KV值读取器

实现了embedded-io的Read和Seek trait,用于流式读取KV值,适合处理大型数据 生命周期'a确保读取器不会超过其关联的KVDB实例的生命周期

Fields§

§entry: KVEntry

Implementations§

Source§

impl<'a, S: NorFlash> KVReader<'a, S>

Source

pub fn new(kvdb: &'a mut KVDB<S>, entry: KVEntry) -> Self

Trait Implementations§

Source§

impl<'a, S: NorFlash> ErrorType for KVReader<'a, S>

Source§

type Error = Error

Error type of all the IO operations on this type.
Source§

impl<'a, S: NorFlash> Read for KVReader<'a, S>

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

从KV值中读取数据到缓冲区

§参数
  • buf: 接收数据的缓冲区
§返回值

成功时返回读取的字节数,失败时返回Error

Source§

fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl<'a, S: NorFlash> Seek for KVReader<'a, S>

Source§

fn seek(&mut self, pos: SeekFrom) -> Result<u64, Self::Error>

调整读取位置

§参数
  • pos: 要定位的位置,支持从开始、当前位置或末尾偏移
§返回值

成功时返回新的位置,失败时返回Error

Source§

fn rewind(&mut self) -> Result<(), Self::Error>

Rewind to the beginning of a stream.
Source§

fn stream_position(&mut self) -> Result<u64, Self::Error>

Returns the current seek position from the start of the stream.

Auto Trait Implementations§

§

impl<'a, S> Freeze for KVReader<'a, S>

§

impl<'a, S> RefUnwindSafe for KVReader<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> !Send for KVReader<'a, S>

§

impl<'a, S> !Sync for KVReader<'a, S>

§

impl<'a, S> Unpin for KVReader<'a, S>

§

impl<'a, S> !UnwindSafe for KVReader<'a, S>

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.