pub struct TSDB<S: NorFlash> { /* private fields */ }Implementations§
Source§impl TSDB<StdStorage>
impl TSDB<StdStorage>
Sourcepub fn new_file(
name: &str,
path: &str,
sec_size: u32,
max_size: u32,
entry_max: usize,
) -> Result<Box<Self>, Error>
pub fn new_file( name: &str, path: &str, sec_size: u32, max_size: u32, entry_max: usize, ) -> Result<Box<Self>, Error>
在 std 环境下,创建一个基于文件的 TSDB 实例。
此函数返回一个 Box<TSDB<StdStorage>>,以确保数据库实例在内存中的地址是稳定的,
防止因栈帧移动导致传递给 C 库的内部指针失效。
§参数
name: 数据库名称path: 数据库文件存储的目录sec_size: 扇区大小max_size: 数据库最大容量entry_max: 单个日志条目的最大长度
Source§impl<S: NorFlash> TSDB<S>
impl<S: NorFlash> TSDB<S>
Sourcepub fn set_name(&mut self, name: &str) -> Result<(), Error>
pub fn set_name(&mut self, name: &str) -> Result<(), Error>
设置数据库名称,仅用于日志输出。
注意: 此方法必须在 init() 之前调用。
Sourcepub fn set_not_formatable(&mut self, enable: bool)
pub fn set_not_formatable(&mut self, enable: bool)
设置数据库为不可格式化模式。
在此模式下,如果数据库初始化时发现头部信息损坏,将返回错误而不是自动格式化。
注意: 此方法必须在 init() 之前调用。
Sourcepub fn not_formatable(&mut self) -> bool
pub fn not_formatable(&mut self) -> bool
检查数据库是否处于不可格式化模式。
Sourcepub fn set_rollover(&mut self, enable: bool)
pub fn set_rollover(&mut self, enable: bool)
启用或禁用翻转写入 (Rollover)。
启用后,当数据库写满时,最旧的数据将被新数据覆盖。
禁用后,数据库写满时 append 操作将返回 SavedFull 错误。
默认启用。
Source§impl<S: NorFlash> TSDB<S>
impl<S: NorFlash> TSDB<S>
Sourcepub fn tsdb_iter<F: FnMut(&mut TSDB<S>, &mut TSLEntry) -> bool + Send>(
&mut self,
callback: F,
reverse: bool,
)
pub fn tsdb_iter<F: FnMut(&mut TSDB<S>, &mut TSLEntry) -> bool + Send>( &mut self, callback: F, reverse: bool, )
Sourcepub fn tsdb_iter_by_time<F: FnMut(&mut TSDB<S>, &mut TSLEntry) -> bool + Send>(
&mut self,
from: i64,
to: i64,
callback: F,
)
pub fn tsdb_iter_by_time<F: FnMut(&mut TSDB<S>, &mut TSLEntry) -> bool + Send>( &mut self, from: i64, to: i64, callback: F, )
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for TSDB<S>where
S: Freeze,
impl<S> RefUnwindSafe for TSDB<S>where
S: RefUnwindSafe,
impl<S> !Send for TSDB<S>
impl<S> !Sync for TSDB<S>
impl<S> Unpin for TSDB<S>where
S: Unpin,
impl<S> UnwindSafe for TSDB<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more