add async feature #1

Merged
b4tman merged 62 commits from async into master 2023-08-18 06:29:46 +00:00
2 changed files with 8 additions and 0 deletions
Showing only changes of commit 5ed0398203 - Show all commits

View File

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