Trait compact::Compact[][src]

pub trait Compact: Sized + Clone {
    fn is_still_compact(&self) -> bool;
fn dynamic_size_bytes(&self) -> usize;
unsafe fn compact(
        source: *mut Self,
        dest: *mut Self,
        new_dynamic_part: *mut u8
    );
unsafe fn decompact(source: *const Self) -> Self; fn total_size_bytes(&self) -> usize { ... }
unsafe fn behind(ptr: *mut Self) -> *mut u8 { ... }
unsafe fn compact_behind(source: *mut Self, dest: *mut Self) { ... } }

A trait for objects with a statically-sized part and a potential dynamically-sized part that can be stored both compactly in consecutive memory or freely on the heap

Required Methods

Is the object's dynamic part stored compactly?

Size of the dynamic part in bytes

Copy the static part of source to dest and compactly store the dynamic part of source as the new dynamic part of dest at new_dynamic_part. This semantically moves source into dest.

Creates a clone of self with the dynamic part guaranteed to be stored freely.

Note: if the dynamic part was already stored freely, the calling environment has to make sure that old self will not be dropped, as this might lead to a double free!

This is mostly used internally to correctly implement Compact datastructures that contain Compact elements.

Provided Methods

Total size of the object (static part + dynamic part)

Get a pointer to behind the static part of self (commonly used place for the dynamic part)

Like compact with new_dynamic_part set to dest.behind()

Implementors