Skip to main content

SharedStringArena

Struct SharedStringArena 

Source
pub struct SharedStringArena { /* private fields */ }

Implementations§

Source§

impl SharedStringArena

Source

pub fn create( path: impl AsRef<Path>, capacity_bytes: usize, ) -> Result<Self, ArenaError>

Source

pub fn open( path: impl AsRef<Path>, expected_capacity_bytes: usize, ) -> Result<Self, ArenaError>

Source

pub fn capacity_bytes(&self) -> usize

Source

pub fn used_bytes(&self) -> usize

Source

pub fn remaining_bytes(&self) -> usize

Source

pub fn intern(&self, s: &str) -> Result<StringRef, ArenaError>

Append a string to the arena. Returns a StringRef that resolves to the bytes in any mapping of the same file.

Returns Err(Full) when the arena has no room. The empty string "" interns at the current offset with len = 0.

Source

pub fn intern_bytes(&self, bytes: &[u8]) -> Result<StringRef, ArenaError>

Append arbitrary bytes (not necessarily UTF-8) to the arena. Useful for storing binary blobs alongside strings. Retrieve with get_bytes; get will reject non-UTF-8 with InvalidUtf8.

Source

pub fn get_bytes(&self, r: StringRef) -> Result<&[u8], ArenaError>

Resolve a StringRef to its &[u8]. Returns Err(InvalidRef) when the ref doesn’t fall inside the arena’s used region.

Source

pub fn get(&self, r: StringRef) -> Result<&str, ArenaError>

Resolve a StringRef to a &str. Returns Err(InvalidUtf8) when the bytes aren’t valid UTF-8 (the arena doesn’t enforce validity per-segment; it’s checked on read).

Source

pub fn intern_and_get(&self, s: &str) -> Result<(StringRef, &str), ArenaError>

Convenience: intern AND return a &str view into the just-written bytes plus the ref.

Source

pub fn clear(&self)

Reset the arena to empty. NOT concurrency-safe; callers must ensure no other threads/processes are interning or reading. Existing StringRefs become invalid (their bytes may be overwritten by subsequent interns).

Source

pub fn flush(&self) -> Result<(), ArenaError>

Source

pub fn flush_async(&self) -> Result<(), ArenaError>

Non-blocking flush: schedules a writeback via the OS. Note: Windows is only partially async (sync to page cache, not to disk).

Trait Implementations§

Source§

impl AdaptiveInstance for SharedStringArena

Source§

fn header(&self) -> &HandshakeHeader

Source§

fn ring(&self) -> &ObservationRing

Source§

fn make_policy(&self) -> Box<dyn Policy>

Source§

fn apply_migration(&self, new_tag: u32)

Called by the sidecar when the policy returns a new strategy tag. Default implementation: just set the tag on the header. Primitives that need heavier migration (data-layout swap) override this to perform the swap before (or after) updating the tag.
Source§

impl Send for SharedStringArena

Source§

impl Sync for SharedStringArena

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.