add async feature #1
@ -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()?;
|
||||||
|
@ -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()?;
|
||||||
|
Loading…
Reference in New Issue
Block a user