[][src]Struct rbx_dom_weak::SharedString

pub struct SharedString { /* fields omitted */ }

A shared buffer of data that is automatically deduplicated so that only one copy of a given buffer is in memory at a time.

SharedString is cheap to clone, since it's internally reference-counted.

This type was introduced by Roblox to help efficiently store data like CSG operation, which was previously kept as BinaryValue objects in CSGDictionaryService.

rbx_dom_weak's implementation of SharedString tries to be faithful to how SharedString works in Roblox, which unfortunately means that it's keyed by MD5 hash. In the event of a hash collision, one of the involved buffers will be silently discarded. It's possible to diverge from this behavior, but could potentially cause edge-case content compatibility issues.

Methods

impl SharedString[src]

pub fn new(data: Vec<u8>) -> SharedString[src]

Constructs a SharedString from a buffer of data.

If the data is already present in memory as a SharedString, this method will return a reference to it, otherwise it'll be inserted.

pub fn md5_hash(&self) -> [u8; 16][src]

Returns the MD5 hash of the SharedString, which is used as unique identifier presently barring hash collisions.

pub fn data(&self) -> &[u8][src]

Returns an immutable reference to the underlying buffer from the SharedString.

Trait Implementations

impl PartialEq<SharedString> for SharedString[src]

impl Drop for SharedString[src]

impl Eq for SharedString[src]

impl Clone for SharedString[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for SharedString[src]

impl Serialize for SharedString[src]

impl<'de> Deserialize<'de> for SharedString[src]

Auto Trait Implementations

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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