pub struct RandomAccessFile { /* private fields */ }
Expand description
A RandomAccessFile in memory. This is not used to serialize data
Implementations§
Source§impl RandomAccessFile
impl RandomAccessFile
pub fn meta(&self) -> &RandomAccessFileMeta
pub fn id(&self) -> &Option<ObjectId>
pub fn key(&self) -> &Option<ObjectKey>
Sourcepub fn new_from_slice(
content: &[u8],
block_size: usize,
content_type: String,
metadata: Vec<u8>,
store: Arc<Store>,
) -> Result<RandomAccessFile, FileError>
pub fn new_from_slice( content: &[u8], block_size: usize, content_type: String, metadata: Vec<u8>, store: Arc<Store>, ) -> Result<RandomAccessFile, FileError>
Creates a new file based on a content that is fully known at the time of creation.
If you want to stream progressively the content into the new file, you should use new_empty(), write() and save() instead
pub fn new_empty( block_size: usize, content_type: String, metadata: Vec<u8>, store: Arc<Store>, ) -> Self
Sourcepub fn write(&mut self, data: &[u8]) -> Result<(), FileError>
pub fn write(&mut self, data: &[u8]) -> Result<(), FileError>
Appends some data at the end of the file currently created with new_empty() and not saved yet. you can call it many times. Don’t forget to eventually call save()
pub fn save(&mut self) -> Result<ObjectId, FileError>
pub fn reference(&self) -> Option<ObjectRef>
Sourcepub fn open(
id: ObjectId,
key: SymKey,
store: Arc<Store>,
) -> Result<RandomAccessFile, FileError>
pub fn open( id: ObjectId, key: SymKey, store: Arc<Store>, ) -> Result<RandomAccessFile, FileError>
Opens a file for read purpose.
pub fn blocks(&self) -> impl Iterator<Item = Block> + '_
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Size once encoded, before deduplication. Only available before save()
Sourcepub fn dedup_size(&self) -> usize
pub fn dedup_size(&self) -> usize
Real size on disk
pub fn depth(&self) -> Result<u8, NgError>
Trait Implementations§
Source§impl Display for RandomAccessFile
impl Display for RandomAccessFile
Source§impl ReadFile for RandomAccessFile
impl ReadFile for RandomAccessFile
Source§fn read(&self, pos: usize, size: usize) -> Result<Vec<u8>, FileError>
fn read(&self, pos: usize, size: usize) -> Result<Vec<u8>, FileError>
reads at most one block from the file. the returned vector should be tested for size. it might be smaller than what you asked for.
pos
ition can be anywhere in the file.
fn get_all_blocks_ids(&self) -> Result<Vec<ObjectId>, FileError>
Auto Trait Implementations§
impl Freeze for RandomAccessFile
impl RefUnwindSafe for RandomAccessFile
impl Send for RandomAccessFile
impl Sync for RandomAccessFile
impl Unpin for RandomAccessFile
impl UnwindSafe for RandomAccessFile
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