UserData

Struct UserData 

Source
pub struct UserData<T, const OVERWRITE: bool = false, const VALUE: u64 = 0>(/* private fields */);
Expand description

UserData is used to push user provided data to the sqvm for storage

UserDataRef can be used to access the data from functions calls

UserData handles dropping the data via a release hook in sqvm

Implementations§

Source§

impl<const OVERWRITE: bool, const VALUE: u64, T: 'static> UserData<T, OVERWRITE, VALUE>

Source

pub fn new(userdata: T) -> Self

Creates a new UserData<T>.

§Example
// cannot be pushed to sqvm normally
struct HttpClient;

#[rrplug::sqfunction(VM = "SERVER | CLIENT | UI")]
fn build_client() -> UserData<HttpClient> {
    UserData::new(HttpClient)
}
Source

pub const fn from_boxed(userdata: Box<T>) -> Self

Creates a new UserData<T> from boxed data

Trait Implementations§

Source§

impl<const OVERWRITE: bool, const VALUE: u64, T: 'static> From<Box<T>> for UserData<T, OVERWRITE, VALUE>

Source§

fn from(value: Box<T>) -> Self

Converts to this type from the input type.
Source§

impl<const OVERWRITE: bool, const VALUE: u64, T: 'static> From<T> for UserData<T, OVERWRITE, VALUE>

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl<const OVERWRITE: bool, const VALUE: u64, T: 'static> PushToSquirrelVm for UserData<T, OVERWRITE, VALUE>

Source§

fn push_to_sqvm( self, sqvm: NonNull<HSquirrelVM>, sqfunctions: &SquirrelFunctions, )

pushes the value to the stack
Source§

impl<const OVERWRITE: bool, const VALUE: u64, T: 'static> SQVMName for UserData<T, OVERWRITE, VALUE>

Source§

fn get_sqvm_name() -> String

the name on the sqvm of a type Read more

Auto Trait Implementations§

§

impl<T, const OVERWRITE: bool, const VALUE: u64> Freeze for UserData<T, OVERWRITE, VALUE>

§

impl<T, const OVERWRITE: bool, const VALUE: u64> RefUnwindSafe for UserData<T, OVERWRITE, VALUE>
where T: RefUnwindSafe,

§

impl<T, const OVERWRITE: bool, const VALUE: u64> Send for UserData<T, OVERWRITE, VALUE>
where T: Send,

§

impl<T, const OVERWRITE: bool, const VALUE: u64> Sync for UserData<T, OVERWRITE, VALUE>
where T: Sync,

§

impl<T, const OVERWRITE: bool, const VALUE: u64> Unpin for UserData<T, OVERWRITE, VALUE>

§

impl<T, const OVERWRITE: bool, const VALUE: u64> UnwindSafe for UserData<T, OVERWRITE, VALUE>
where T: UnwindSafe,

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

Source§

fn from(t: !) -> T

Converts to this type from the input type.
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> IntoSquirrelArgs for T

Source§

fn into_push( self, sqvm: NonNull<HSquirrelVM>, sqfunctions: &'static SquirrelFunctions, ) -> i32

pushes the args to the sqvm and returns the amount pushed
Source§

fn into_function( self, ) -> Box<dyn FnOnce(NonNull<HSquirrelVM>, &'static SquirrelFunctions) -> i32 + Send + Sync + 'static>
where Self: Sized + Send + Sync + 'static,

converts a implemenator of this trait into a closure that pushes it to the squirrel stack when ran
Source§

impl<T> ReturnToVm for T

Source§

fn return_to_vm( self, sqvm: NonNull<HSquirrelVM>, sqfunctions: &SquirrelFunctions, ) -> SQRESULT

any return for types simply pushes it and returns NonNull

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.