gix_odb::memory

Struct Proxy

source
pub struct Proxy<T> { /* private fields */ }
Expand description

An object database to read from any implementation but write to memory. Previously written objects can be returned from memory upon query, which makes the view of objects consistent. In-Memory objects can be disabled by taking out its storage. From there in-memory object can also be persisted one by one.

It’s possible to turn off the memory by removing it from the instance.

Implementations§

source§

impl<T> Proxy<T>

Lifecycle

source

pub fn new(odb: T, object_hash: Kind) -> Proxy<T>

Create a new instance using odb as actual object provider, with an empty in-memory store for objects that are to be written. Use object_hash to determine the kind of hash to produce when writing new objects.

source

pub fn into_inner(self) -> T

Turn ourselves into our inner object database, while deallocating objects stored in memory.

source

pub fn with_write_passthrough(self) -> Self

Strip object memory off this instance, which means that writes will go through to the inner object database right away. This mode makes the proxy fully transparent.

source§

impl Proxy<Cache<Handle<Arc<Store>>>>

source

pub fn into_arc(self) -> Result<Proxy<Cache<Handle<Arc<Store>>>>>

No op, as we are containing an arc handle already.

source§

impl Proxy<Cache<Handle<Rc<Store>>>>

source

pub fn into_arc(self) -> Result<Proxy<Cache<Handle<Arc<Store>>>>>

Create an entirely new instance, but with the in-memory objects moving between them.

source§

impl<T> Proxy<T>

Memory Access

source

pub fn take_object_memory(&mut self) -> Option<Storage>

Take all the objects in memory so far, with the memory storage itself and return it.

The instance will remain in a state where it won’t be able to store objects in memory at all, they will now be stored in the underlying object database. This mode makes the proxy fully transparent.

To avoid that, use reset_object_memory() or return the storage using set_object_memory().

source

pub fn set_object_memory(&mut self, new: Storage) -> Option<Storage>

Set the object storage to contain only new objects, and return whichever objects were there previously.

source

pub fn enable_object_memory(&mut self) -> &mut Self

If objects aren’t written to memory yet, this will happen after the call.

Otherwise, no change will be performed.

source

pub fn reset_object_memory(&self) -> Option<Storage>

Reset the internal storage to be empty, and return the previous storage, with all objects it contained.

Note that this does nothing if this instance didn’t contain object memory in the first place. In that case, set it explicitly.

source

pub fn num_objects_in_memory(&self) -> usize

Return the amount of objects currently stored in memory.

Trait Implementations§

source§

impl<T> Clone for Proxy<T>
where T: Clone,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Deref for Proxy<T>

source§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T> DerefMut for Proxy<T>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<T> Exists for Proxy<T>
where T: Exists,

source§

fn exists(&self, id: &oid) -> bool

Returns true if the object exists in the database.
source§

impl<T> Find for Proxy<T>
where T: Find,

source§

fn try_find<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<Option<Data<'a>>, Error>

Find an object matching id in the database while placing its raw, possibly encoded data into buffer. Read more
source§

impl<T> Header for Proxy<T>
where T: FindHeader,

source§

fn try_header(&self, id: &oid) -> Result<Option<Header>, Error>

Find the header of the object matching id in the database. Read more
source§

impl From<Cache<Handle<Rc<Store>>>> for Proxy<Handle>

source§

fn from(odb: Handle) -> Self

Converts to this type from the input type.
source§

impl<T> Header for Proxy<T>
where T: Header,

source§

fn try_header(&self, id: &oid) -> Result<Option<Header>, Error>

Try to read the header of the object associated with id or return None if it could not be found.
source§

impl<T> Write for Proxy<T>
where T: Write,

source§

fn write_stream( &self, kind: Kind, size: u64, from: &mut dyn Read, ) -> Result<ObjectId, Error>

As write, but takes an input stream. This is commonly used for writing blobs directly without reading them to memory first.
source§

fn write(&self, object: &dyn WriteTo) -> Result<ObjectId, Error>

Write objects using the intrinsic kind of hash into the database, returning id to reference it in subsequent reads.
source§

fn write_buf(&self, object: Kind, from: &[u8]) -> Result<ObjectId, Error>

As write, but takes an object kind along with its encoded bytes.

Auto Trait Implementations§

§

impl<T> !Freeze for Proxy<T>

§

impl<T> !RefUnwindSafe for Proxy<T>

§

impl<T> Send for Proxy<T>
where T: Send,

§

impl<T> !Sync for Proxy<T>

§

impl<T> Unpin for Proxy<T>
where T: Unpin,

§

impl<T> UnwindSafe for Proxy<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T, A, P> Access<T> for P
where A: Access<T> + ?Sized, P: Deref<Target = A>,

source§

type Guard = <A as Access<T>>::Guard

A guard object containing the value and keeping it alive. Read more
source§

fn load(&self) -> <P as Access<T>>::Guard

The loading method. Read more
source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T, A> DynAccess<T> for A
where A: Access<T>, <A as Access<T>>::Guard: 'static,

source§

fn load(&self) -> DynGuard<T>

The equivalent of Access::load.
source§

impl<T> FindExt for T
where T: Find + ?Sized,

source§

fn find<'a>(&self, id: &oid, buffer: &'a mut Vec<u8>) -> Result<Data<'a>, Error>

Like try_find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error.
source§

fn find_commit<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<CommitRef<'a>, Error>

Like find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error while returning the desired object type.
source§

fn find_tree<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<TreeRef<'a>, Error>

Like find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error while returning the desired object type.
source§

fn find_tag<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<TagRef<'a>, Error>

Like find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error while returning the desired object type.
source§

fn find_blob<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<BlobRef<'a>, Error>

Like find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error while returning the desired object type.
source§

fn find_commit_iter<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<CommitRefIter<'a>, Error>

Like find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error while returning the desired iterator type.
source§

fn find_tree_iter<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<TreeRefIter<'a>, Error>

Like find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error while returning the desired iterator type.
source§

fn find_tag_iter<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<TagRefIter<'a>, Error>

Like find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error while returning the desired iterator type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> HeaderExt for T
where T: Header,

source§

fn header(&self, id: impl AsRef<oid>) -> Result<Header, Error>

Like try_header(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error.
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> FindObjectOrHeader for T
where T: Find + Header,