Skip to main content

SsabResource

Struct SsabResource 

Source
pub struct SsabResource { /* private fields */ }
Expand description

A thread-safe, shared resource containing SSAB data and its parsed metadata.

This is a self-referential structure: resource holds borrows into data’s buffer. The 'static lifetime stored internally is fictitious — the actual lifetime is bound to &self. The resource() accessor restores the correct lifetime, so external code never observes the unsound 'static form.

Invariants (must hold for soundness):

  • Fields are private so data cannot be mutated or replaced after construction.
  • Field declaration order ensures resource is dropped before data.
  • An owned SsabData keeps its Vec<u8> buffer at a stable heap address; a borrowed one requires the caller to keep the memory valid (documented on SsabData::load_borrow).

Implementations§

Source§

impl SsabResource

Source

pub unsafe fn new(data: SsabData) -> Arc<Self> ⓘ

Parses data into a shareable resource. On failure the resource holds no animation and Self::parse_error says why.

§Safety

The bytes must be a valid .ssab. They are read through FlatBuffers accessors that do not bounds-check in release builds, so any other bytes are undefined behaviour (out-of-bounds reads). A pack the converter wrote is valid; for any other, run the FlatBuffers verifier first (the ssab crate’s checked root_as_ss_anime_binary).

Source

pub fn parse_error(&self) -> Option<&SSRuntimeError>

Why Self::resource is None, or None when the parse succeeded.

Source

pub fn resource(&self) -> Option<&AnimationResource<'_>>

Returns the parsed animation resource, with its lifetime tied to &self.

Source

pub fn data(&self) -> &SsabData

Returns the underlying SSAB data.

Source

pub fn resource_static_ptr(&self) -> *const AnimationResource<'static>

Returns a raw pointer to the parsed resource (or null if parsing failed), detached from self’s borrow scope.

This is intended for FFI/WASM bindings that need to extend the resource reference into a 'static context while transferring ownership of the surrounding Arc<SsabResource> to a long-lived holder. Using a raw pointer breaks the borrow chain so the Arc can be moved into its holder before the pointer is dereferenced.

Obtaining the pointer is safe; dereferencing it is unsafe and the caller must uphold the obligations below.

§Caller obligations when dereferencing
  • Keep some Arc<SsabResource> pointing at this allocation alive for the entire duration the pointer (or any borrow derived from it) is in use.
  • Do not dereference after the last Arc referencing this allocation is dropped — doing so is undefined behaviour.

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more