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>
impl<const OVERWRITE: bool, const VALUE: u64, T: 'static> UserData<T, OVERWRITE, VALUE>
Sourcepub fn new(userdata: T) -> Self
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)
}Sourcepub const fn from_boxed(userdata: Box<T>) -> Self
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>
impl<const OVERWRITE: bool, const VALUE: u64, T: 'static> From<Box<T>> for UserData<T, OVERWRITE, VALUE>
Source§impl<const OVERWRITE: bool, const VALUE: u64, T: 'static> From<T> for UserData<T, OVERWRITE, VALUE>
impl<const OVERWRITE: bool, const VALUE: u64, T: 'static> From<T> for UserData<T, OVERWRITE, VALUE>
Source§impl<const OVERWRITE: bool, const VALUE: u64, T: 'static> PushToSquirrelVm for UserData<T, OVERWRITE, VALUE>
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,
)
fn push_to_sqvm( self, sqvm: NonNull<HSquirrelVM>, sqfunctions: &SquirrelFunctions, )
pushes the value to the stack
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoSquirrelArgs for Twhere
T: PushToSquirrelVm,
impl<T> IntoSquirrelArgs for Twhere
T: PushToSquirrelVm,
Source§fn into_push(
self,
sqvm: NonNull<HSquirrelVM>,
sqfunctions: &'static SquirrelFunctions,
) -> i32
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>
fn into_function( self, ) -> Box<dyn FnOnce(NonNull<HSquirrelVM>, &'static SquirrelFunctions) -> i32 + 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 Twhere
T: PushToSquirrelVm,
impl<T> ReturnToVm for Twhere
T: PushToSquirrelVm,
Source§fn return_to_vm(
self,
sqvm: NonNull<HSquirrelVM>,
sqfunctions: &SquirrelFunctions,
) -> SQRESULT
fn return_to_vm( self, sqvm: NonNull<HSquirrelVM>, sqfunctions: &SquirrelFunctions, ) -> SQRESULT
any return for types simply pushes it and returns NonNull