formatting
This commit is contained in:
parent
ad98cfafb2
commit
c25c6edc6a
29 changed files with 886 additions and 571 deletions
|
|
@ -1,14 +1,14 @@
|
|||
use async_trait::async_trait;
|
||||
|
||||
use crate::binary_coding::encode;
|
||||
use bincode;
|
||||
use bincode::Encode;
|
||||
use crate::binary_coding::encode;
|
||||
|
||||
use crate::cursor_capabilities::primitive::{CursorCanRead, CursorCanWrite};
|
||||
use crate::cursor_capabilities::traversal::CursorCanTraverse;
|
||||
use crate::segments::entry::Entry;
|
||||
use crate::segments::store_header::StoreHeader;
|
||||
use crate::store::{FilePosition, Result};
|
||||
use crate::cursor_capabilities::primitive::{CursorCanRead, CursorCanWrite};
|
||||
use crate::cursor_capabilities::traversal::CursorCanTraverse;
|
||||
|
||||
#[async_trait]
|
||||
pub trait CursorCanModifyEntries<T>: CursorCanTraverse<T> + CursorCanWrite<T> {
|
||||
|
|
@ -16,8 +16,9 @@ pub trait CursorCanModifyEntries<T>: CursorCanTraverse<T> + CursorCanWrite<T> {
|
|||
fn set_eof_file_position(&mut self, new_file_position: FilePosition);
|
||||
|
||||
// ===Store Header Manipulation===
|
||||
async fn increment_total_count(&mut self) -> Result<()>
|
||||
where T: Send
|
||||
async fn increment_total_count(&mut self) -> Result<()>
|
||||
where
|
||||
T: Send,
|
||||
{
|
||||
self.seek_to_start().await?;
|
||||
self.seek_to(StoreHeader::TOTAL_COUNT_OFFSET as u64).await?;
|
||||
|
|
@ -26,18 +27,21 @@ pub trait CursorCanModifyEntries<T>: CursorCanTraverse<T> + CursorCanWrite<T> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
async fn increment_deleted_count(&mut self) -> Result<()>
|
||||
where T: Send
|
||||
async fn increment_deleted_count(&mut self) -> Result<()>
|
||||
where
|
||||
T: Send,
|
||||
{
|
||||
self.seek_to_start().await?;
|
||||
self.seek_to(StoreHeader::DELETED_COUNT_OFFSET as u64).await?;
|
||||
self.seek_to(StoreHeader::DELETED_COUNT_OFFSET as u64)
|
||||
.await?;
|
||||
let new_count = self.header_mut().increment_deleted_count();
|
||||
self.write_bytes(&encode::<usize>(&new_count)?).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn set_header(&mut self, header: &StoreHeader) -> Result<()>
|
||||
where T: Send
|
||||
async fn set_header(&mut self, header: &StoreHeader) -> Result<()>
|
||||
where
|
||||
T: Send,
|
||||
{
|
||||
self.seek_to_start().await?;
|
||||
let encoded_header: Vec<u8> = header.encode()?;
|
||||
|
|
@ -50,8 +54,9 @@ pub trait CursorCanModifyEntries<T>: CursorCanTraverse<T> + CursorCanWrite<T> {
|
|||
|
||||
// Moves cursor to the end.
|
||||
// Returns file position to the start of the new entry.
|
||||
async fn append_entry_no_indexing(&mut self, entry: &Entry<T>) -> Result<FilePosition>
|
||||
where T: Encode + Send + Sync
|
||||
async fn append_entry_no_indexing(&mut self, entry: &Entry<T>) -> Result<FilePosition>
|
||||
where
|
||||
T: Encode + Send + Sync,
|
||||
{
|
||||
self.increment_total_count().await?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue