Skip to main content

Tasks

Struct Tasks 

Source
pub struct Tasks<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Tasks<'a>

Source

pub fn kv_get(&self, key: impl AsRef<[u8]>) -> Result<Option<Vec<u8>>>

Source

pub fn kv_put(&self, key: impl AsRef<[u8]>, value: &[u8]) -> Result<()>

Source

pub fn kv_delete(&self, key: impl AsRef<[u8]>) -> Result<bool>

返回键之前是否存在。

Source

pub fn kv_keys(&self, prefix: impl AsRef<[u8]>) -> Result<Vec<Vec<u8>>>

以 prefix 开头的所有键,按字节序排序。要逐条读盘,适合启动时列出未完成任务这类低频操作。

Source

pub fn list_push(&self, list: impl AsRef<[u8]>, item: &[u8]) -> Result<u64>

追加到列表尾部,返回序号。

Source

pub fn list_pop_front(&self, list: impl AsRef<[u8]>) -> Result<Option<Vec<u8>>>

弹出列表头部。

Source

pub fn list_front(&self, list: impl AsRef<[u8]>) -> Result<Option<Vec<u8>>>

Source

pub fn list_len(&self, list: impl AsRef<[u8]>) -> u64

Source

pub fn list_items( &self, list: impl AsRef<[u8]>, limit: usize, ) -> Result<Vec<Vec<u8>>>

从头部开始最多 limit 个元素。

Source

pub fn list_range( &self, list: impl AsRef<[u8]>, from: u64, limit: usize, ) -> Result<Vec<Vec<u8>>>

从序号 from 开始最多 limit 个元素,跳过已弹出的。只追加、不弹出的列表里序号就是下标, 可以用来分页。

Source

pub fn list_clear(&self, list: impl AsRef<[u8]>) -> Result<u64>

清空列表,返回删除的元素个数。

Source

pub fn set_insert( &self, set: impl AsRef<[u8]>, member: impl AsRef<[u8]>, ) -> Result<bool>

返回是否是新加入的成员。

Source

pub fn set_contains( &self, set: impl AsRef<[u8]>, member: impl AsRef<[u8]>, ) -> Result<bool>

Source

pub fn set_remove( &self, set: impl AsRef<[u8]>, member: impl AsRef<[u8]>, ) -> Result<bool>

Source

pub fn set_len(&self, set: impl AsRef<[u8]>) -> u64

Source

pub fn set_members(&self, set: impl AsRef<[u8]>) -> Result<Vec<Vec<u8>>>

所有成员(逐条读盘,低频使用)。

Source

pub fn set_clear(&self, set: impl AsRef<[u8]>) -> Result<u64>

清空集合,返回删除的成员个数。

Auto Trait Implementations§

§

impl<'a> Freeze for Tasks<'a>

§

impl<'a> RefUnwindSafe for Tasks<'a>

§

impl<'a> Send for Tasks<'a>

§

impl<'a> Sync for Tasks<'a>

§

impl<'a> Unpin for Tasks<'a>

§

impl<'a> UnsafeUnpin for Tasks<'a>

§

impl<'a> UnwindSafe for Tasks<'a>

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.