Skip to main content

GetShared

Enum GetShared 

Source
pub enum GetShared {
    Arc(Arc<Box<[u8]>>),
    Bytes(Vec<u8>),
}
Expand description

Owned GET result for the FFI zero-copy shared lane (Store::get_shared_owned). Bulk values ride out as an Arc clone (no byte copy); small values as a plain Vec (one alloc — cheaper than a fresh Arc). The FFI’s shared free reconstructs whichever the tag says.

use kevy_store::{GetShared, SetCondition, Store};
let mut s = Store::new();
s.set(b"k", b"v".to_vec(), None, SetCondition::Always);
assert!(matches!(s.get_shared_owned(b"k")?, Some(GetShared::Bytes(_))));
assert!(s.get_shared_owned(b"missing")?.is_none());

Variants§

§

Arc(Arc<Box<[u8]>>)

Bulk value — the engine’s Arc, cloned. Zero byte copy.

use kevy_store::{GetShared, SetCondition, Store};
let mut s = Store::new();
s.set(b"big", vec![b'x'; 1024], None, SetCondition::Always);
let Some(GetShared::Arc(a)) = s.get_shared_owned(b"big")? else { panic!() };
assert_eq!(a.len(), 1024);
§

Bytes(Vec<u8>)

Small value (Str/Int) — a plain owned Vec, one allocation.

use kevy_store::{GetShared, SetCondition, Store};
let mut s = Store::new();
s.set(b"n", b"7".to_vec(), None, SetCondition::Always);
let Some(GetShared::Bytes(b)) = s.get_shared_owned(b"n")? else { panic!() };
assert_eq!(b, b"7");

Trait Implementations§

Source§

impl Debug for GetShared

Source§

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

Formats the value using the given formatter. 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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.