Type Alias gix_odb::Handle

source ·
pub type Handle = Cache<Handle<OwnShared<Store>>>;
Expand description

A thread-local handle to access any object.

Aliased Type§

struct Handle { /* private fields */ }

Implementations§

source§

impl Cache<Handle<Rc<Store>>>

source

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

Convert this cache’s handle into one that keeps its store in an arc. This creates an entirely new store, so should be done early to avoid unnecessary work (and mappings).

source§

impl<S> Cache<S>

source

pub fn into_inner(self) -> S

Dissolve this instance, discard all caches, and return the inner implementation.

source

pub fn with_pack_cache( self, create: impl Fn() -> Box<PackCache> + Send + Sync + 'static ) -> Self

Use this methods directly after creating a new instance to add a constructor for pack caches.

These are used to speed up decoding objects which are located in packs, reducing long delta chains by storing their intermediate results.

source

pub fn with_object_cache( self, create: impl Fn() -> Box<ObjectCache> + Send + Sync + 'static ) -> Self

Use this methods directly after creating a new instance to add a constructor for object caches.

Only use this kind of cache if the same objects are repeatedly accessed for great speedups, usually during diffing of trees.

source

pub fn set_pack_cache( &mut self, create: impl Fn() -> Box<PackCache> + Send + Sync + 'static )

Set the pack cache constructor on this instance.

source

pub fn set_object_cache( &mut self, create: impl Fn() -> Box<ObjectCache> + Send + Sync + 'static )

Set the object cache constructor on this instance.

source

pub fn has_object_cache(&self) -> bool

Return true if an object cache is present.

source

pub fn has_pack_cache(&self) -> bool

Return true if a pack cache is present.

source

pub fn unset_pack_cache(&mut self)

Remove the current pack cache as well as its constructor from this instance.

source

pub fn unset_object_cache(&mut self)

Remove the current object cache as well as its constructor from this instance.

Trait Implementations§

source§

impl<S: Clone> Clone for Cache<S>

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<S> Deref for Cache<S>

§

type Target = S

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

impl<S> DerefMut for Cache<S>

source§

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

Mutably dereferences the value.
source§

impl<S> Find for Cache<S>where S: Find,

source§

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

Returns true if the object exists in the database.
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<S> Find for Cache<S>where S: Find,

source§

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

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

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

Find an object matching id in the database while placing its raw, decoded data into buffer. A pack_cache can be used to speed up subsequent lookups, set it to crate::cache::Never if the workload isn’t suitable for caching. Read more
source§

fn try_find_cached<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, pack_cache: &mut dyn DecodeEntry ) -> Result<Option<(Data<'a>, Option<Location>)>, Error>

Like Find::try_find(), but with support for controlling the pack cache. A pack_cache can be used to speed up subsequent lookups, set it to crate::cache::Never if the workload isn’t suitable for caching. Read more
source§

fn location_by_oid(&self, id: &oid, buf: &mut Vec<u8>) -> Option<Location>

Find the packs location where an object with id can be found in the database, or None if there is no pack holding the object. Read more
source§

fn pack_offsets_and_oid(&self, pack_id: u32) -> Option<Vec<(u64, ObjectId)>>

Obtain a vector of all offsets, in index order, along with their object id.
source§

fn entry_by_location(&self, location: &Location) -> Option<Entry>

Return the find::Entry for location if it is backed by a pack. Read more
source§

impl<S> From<S> for Cache<S>where S: Find,

source§

fn from(store: S) -> Self

Converts to this type from the input type.
source§

impl<S> Header for Cache<S>where S: 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<S> Write for Cache<S>where S: 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.