db(+async) writer: add push_by_ref

This commit is contained in:
Dmitry Belyaev 2023-08-15 11:03:15 +03:00
parent 9196c61a12
commit 5ed0398203
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3
2 changed files with 8 additions and 0 deletions

View File

@ -84,6 +84,10 @@ where
}
pub async fn push(&mut self, item: T) -> Result<(), String> {
self.push_by_ref(&item).await
}
pub async fn push_by_ref(&mut self, item: &T) -> Result<(), String> {
let pos: LSize = self.data_buf.len() as LSize;
bincode::encode_into_writer(item, &mut self.cur_buf_item, BINCODE_CFG).str_err()?;

View File

@ -77,6 +77,10 @@ where
}
pub fn push(&mut self, item: T) -> Result<(), String> {
self.push_by_ref(&item)
}
pub fn push_by_ref(&mut self, item: &T) -> Result<(), String> {
let pos: LSize = self.data_buf.position() as LSize;
bincode::encode_into_writer(item, &mut self.cur_buf_item, BINCODE_CFG).str_err()?;