pub struct HighSpeedCache<T, const LEN: usize> { /* private fields */ }Implementations§
Source§impl<T, const LEN: usize> HighSpeedCache<T, LEN>where
T: CacheData,
impl<T, const LEN: usize> HighSpeedCache<T, LEN>where
T: CacheData,
Sourcepub fn with_capacity(_capacity: usize) -> Self
pub fn with_capacity(_capacity: usize) -> Self
创建一个新的高速缓存,与 Vec 的 with_capacity 方法类似 注意:因为内部已经使用固定大小的数组,参数 capacity 仅用于保持 API 风格一致性
pub fn new() -> Self
Sourcepub fn find_找之前的项(
&self,
毫秒数: i64,
is_找不到即取最新数据: bool,
) -> Option<&T>
pub fn find_找之前的项( &self, 毫秒数: i64, is_找不到即取最新数据: bool, ) -> Option<&T>
传参:毫秒 如果找不到精确定位的数据, 则返回最新的那条数据
Sourcepub fn find_limit<F: Fn(&T, &T) -> bool>(
&self,
n: i64,
is_return_last: bool,
compare: F,
) -> T
pub fn find_limit<F: Fn(&T, &T) -> bool>( &self, n: i64, is_return_last: bool, compare: F, ) -> T
如果十档或者前封单数据如果出现断档的情况,那么把前一个数据的时间戳改成现在数据并且减10毫秒 下次找数据时可以直接找到这一条 找到范围内最大的值 n: 毫秒数 is_return_last: true; 两秒内最大值找不到, 即找一个最新的数据 compare: 比较两个值, 返回true则使用新的值
TODO: 不要使用补数据的逻辑, 找不到数据即取一个最新的数据
Sourcepub fn list_items_len(&self, count: usize) -> Vec<&T>
pub fn list_items_len(&self, count: usize) -> Vec<&T>
传参:找多少个
Sourcepub fn list_items(&self, 毫秒数: i64) -> Vec<&T>
pub fn list_items(&self, 毫秒数: i64) -> Vec<&T>
传参:毫秒
Source§impl<T, const LEN: usize> HighSpeedCache<T, LEN>where
T: CacheData,
impl<T, const LEN: usize> HighSpeedCache<T, LEN>where
T: CacheData,
Sourcepub fn iter(&self) -> HighSpeedCacheIter<'_, T, LEN> ⓘ
pub fn iter(&self) -> HighSpeedCacheIter<'_, T, LEN> ⓘ
返回一个引用迭代器,按从最新到最旧的顺序
Sourcepub fn iter_mut(&mut self) -> HighSpeedCacheIterMut<'_, T, LEN> ⓘ
pub fn iter_mut(&mut self) -> HighSpeedCacheIterMut<'_, T, LEN> ⓘ
返回一个可变引用迭代器,按从最新到最旧的顺序
Trait Implementations§
Source§impl<T, const LEN: usize> Deref for HighSpeedCache<T, LEN>
impl<T, const LEN: usize> Deref for HighSpeedCache<T, LEN>
Source§impl<'a, T, const LEN: usize> IntoIterator for &'a HighSpeedCache<T, LEN>where
T: CacheData,
impl<'a, T, const LEN: usize> IntoIterator for &'a HighSpeedCache<T, LEN>where
T: CacheData,
Source§impl<'a, T, const LEN: usize> IntoIterator for &'a mut HighSpeedCache<T, LEN>where
T: CacheData,
impl<'a, T, const LEN: usize> IntoIterator for &'a mut HighSpeedCache<T, LEN>where
T: CacheData,
Source§impl<T, const LEN: usize> IntoIterator for HighSpeedCache<T, LEN>
impl<T, const LEN: usize> IntoIterator for HighSpeedCache<T, LEN>
Auto Trait Implementations§
impl<T, const LEN: usize> !Freeze for HighSpeedCache<T, LEN>
impl<T, const LEN: usize> !RefUnwindSafe for HighSpeedCache<T, LEN>
impl<T, const LEN: usize> Send for HighSpeedCache<T, LEN>where
T: Send,
impl<T, const LEN: usize> Sync for HighSpeedCache<T, LEN>
impl<T, const LEN: usize> Unpin for HighSpeedCache<T, LEN>where
T: Unpin,
impl<T, const LEN: usize> UnwindSafe for HighSpeedCache<T, LEN>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more