pub struct RendererObject<'a> { /* private fields */ }
Expand description

A wrapper around a user data void pointer found on a few Spine C structs.

The Spine C runtime sets this automatically to the attachment’s atlas region for region and mesh attachments if using the default atlas attachment loader. In this case, get_atlas_region can be used to get the Rust struct.

The value can be set manually but will panic if the value is already set. The previous value can be disposed using dispose, but only if the value was allocated in Rust. The value can be forgotten using forget, but this can cause a memory leak.

Implementations§

source§

impl<'a> RendererObject<'a>

source

pub fn set<T>(&mut self, data: T)

Set the renderer object to a Rust object. Panics if the renderer object is already set. Must be manually freed later using dispose.

§Panics

Panics if the renderer object is already set or if given a zero sized type.

source

pub unsafe fn get<T>(&mut self) -> Option<&mut T>

Gets the type pointed to by this renderer object.

§Safety

It is not guaranteed that the returned option has a valid object and could segfault if the renderer object is a different type than requested.

source

pub unsafe fn get_unchecked<T>(&mut self) -> &mut T

Gets the type pointed to by this renderer object without a null check.

§Safety

It is not guaranteed that the returned option has a valid object and could segfault if the renderer object is a different type than requested.

source

pub unsafe fn get_atlas_region( &mut self ) -> Option<CTmpRef<'_, Self, AtlasRegion>>

Gets the atlas region on mesh and region attachments if the default attachment loader was used to create the skeleton.

§Safety

This function does not guarantee that the returned option has a valid AtlasRegion and could segfault if the renderer object is a different type.

source

pub unsafe fn dispose<T>(&mut self)

Drop the underlying data.

§Safety

Must only be called after setting the render object to a Rust type. Might segfault if pointing to a type that was allocated in C.

source

pub fn forget(&mut self)

Set renderer object to null, potentially leaking the memory previously pointed to.

Auto Trait Implementations§

§

impl<'a> Freeze for RendererObject<'a>

§

impl<'a> RefUnwindSafe for RendererObject<'a>

§

impl<'a> !Send for RendererObject<'a>

§

impl<'a> !Sync for RendererObject<'a>

§

impl<'a> Unpin for RendererObject<'a>

§

impl<'a> !UnwindSafe for RendererObject<'a>

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

§

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

§

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.