CacheObject

Struct CacheObject 

Source
pub struct CacheObject {
    pub offset: usize,
    pub data_decompressed: Vec<u8>,
    pub mem_recorder: Option<Arc<AtomicUsize>>,
    /* private fields */
}

Fields§

§offset: usize§data_decompressed: Vec<u8>§mem_recorder: Option<Arc<AtomicUsize>>

Implementations§

Source§

impl CacheObject

Source

pub fn new_for_undeltified( obj_type: ObjectType, data: Vec<u8>, offset: usize, ) -> Self

Create a new CacheObject which is neither ObjectType::OffsetDelta nor ObjectType::HashDelta.

Source

pub fn object_type(&self) -> ObjectType

Get the ObjectType of the object.

Source

pub fn base_object_hash(&self) -> Option<SHA1>

Get the SHA1 hash of the object.

If the object is a delta object, return None.

Source

pub fn offset_delta(&self) -> Option<usize>

Get the offset delta of the object.

If the object is not an offset delta, return None.

Source

pub fn hash_delta(&self) -> Option<SHA1>

Get the hash delta of the object.

If the object is not a hash delta, return None.

Source

pub fn to_entry(&self) -> Entry

transform the CacheObject to Entry

Trait Implementations§

Source§

impl Clone for CacheObject

Source§

fn clone(&self) -> Self

Returns a duplicate 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 Debug for CacheObject

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for CacheObject

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Drop for CacheObject

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl HeapSize for CacheObject

Source§

fn heap_size(&self) -> usize

If a CacheObject is ObjectType::HashDelta or ObjectType::OffsetDelta, it will expand to another CacheObject of other types. To prevent potential OOM, we record the size of the expanded object as well as that of the object itself.

Base objects, i.e., ObjectType::Blob, ObjectType::Tree, ObjectType::Commit, and ObjectType::Tag, will not be expanded, so the heap-size of the object is the same as the size of the data.

See Comment in PR #755 for more details.

Source§

fn heap_size_sum_iter<'item, Fun, Iter>(make_iter: Fun) -> usize
where Self: 'item, Fun: Fn() -> Iter, Iter: Iterator<Item = &'item Self>,

The total sum of the sizes of referenced data that is owned by a value in an iterator constructed with the given constructor, in bytes. This is default-implemented by computing HeapSize::heap_size on every element and summing them. In some cases, specialized implementations may be more performant. This is common for types which do not allocate any memory at all, where this function can be implemented by a constant zero. Read more
Source§

fn heap_size_sum_exact_size_iter<'item, Fun, Iter>(make_iter: Fun) -> usize
where Self: 'item, Fun: Fn() -> Iter, Iter: ExactSizeIterator<Item = &'item Self>,

The total sum of the sizes of referenced data that is owned by a value in an exact-size-iterator constructed with the given constructor, in bytes. This is default-implemented by using HeapSize::heap_size_sum_iter. In some cases, specialized implementations relying on the iterator’s size may be more performant. This is common for types which allocate a constant amount of memory, where this function can multiply the iterator’s length. Read more
Source§

impl MemSizeRecorder for CacheObject

Source§

fn record_mem_size(&self)

record the mem-size of this CacheObj in a static var
since that, DO NOT modify CacheObj after recording

Source§

fn set_mem_recorder(&mut self, mem_recorder: Arc<AtomicUsize>)

Source§

impl Serialize for CacheObject

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

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, dest: *mut u8)

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

impl<T> FileLoadStore for T
where T: Serialize + for<'a> Deserialize<'a>,

Source§

fn f_load(path: &Path) -> Result<T, Error>

Source§

fn f_save(&self, path: &Path) -> Result<(), Error>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MemSize for T
where T: HeapSize + ValueSize + ?Sized,

Source§

fn mem_size(&self) -> usize

The total size of this value in bytes. This includes the value itself as well as all owned referenced data (such as the value on the heap of a Box or the elements and reserved memory of a Vec). Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> ValueSize for T

Source§

fn value_size(&self) -> usize

The size of this value in bytes, excluding allocated data. Read more
Source§

fn value_size_sum_iter<'item>(iterator: impl Iterator<Item = &'item T>) -> usize
where T: 'item,

The total sum of the sizes of all values in the given iterator, in bytes. This is default-implemented by computing ValueSize::value_size on every element and summing them. For Sized types, a more potentially efficient implementation using Iterator::count is provided. If you are implementing this trait manually, it is unlikely to be more efficient to provide a manual implementation here. Read more
Source§

fn value_size_sum_exact_size_iter<'item>( iterator: impl ExactSizeIterator<Item = &'item T>, ) -> usize
where T: 'item,

The total sum of the sizes of all values in the given exact-size-iterator, in bytes. This is default-implemented by using ValueSize::value_size_sum_iter. For Sized types, a usually more efficient implementation using ExactSizeIterator::len is provided. If you are implementing this trait manually, it is unlikely to be more efficient to provide a manual implementation here. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ArcWrapperBounds for T
where T: HeapSize + Serialize + for<'a> Deserialize<'a> + Send + Sync + 'static,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,