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, Box<dyn Error + Sync + Send>>

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, Box<dyn Error + Sync + Send>>

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 u8)

🔬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_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_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_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_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_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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
Available on non-bootstrap only.
The target type on which the method may be called.
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,