commonlibsse_ng\skse\interfaces/
object.rs

1// C++ Original code
2// - ref: https://github.com/SARDONYX-forks/CommonLibVR/blob/ng/include/SKSE/Interfaces.h
3// - ref: https://github.com/SARDONYX-forks/CommonLibVR/blob/ng/src/SKSE/Interfaces.cpp
4// SPDX-FileCopyrightText: (C) 2018 Ryan-rsm-McKenzie
5// SPDX-License-Identifier: MIT
6//
7// SPDX-FileCopyrightText: (C) 2025 SARDONYX
8// SPDX-License-Identifier: Apache-2.0 OR MIT
9
10use crate::skse::impls::stab::{
11    SKSEDelayFunctorManager, SKSEObjectInterface, SKSEObjectRegistry, SKSEPersistentObjectStorage,
12};
13
14#[derive(Debug, Clone)]
15#[repr(transparent)]
16pub struct ObjectInterface(&'static SKSEObjectInterface);
17
18impl ObjectInterface {
19    pub const VERSION: u32 = 2;
20
21    #[inline]
22    pub(crate) const fn new(interface: &'static SKSEObjectInterface) -> Self {
23        Self(interface)
24    }
25
26    #[inline]
27    pub const fn version(&self) -> u32 {
28        self.0.interfaceVersion
29    }
30
31    #[inline]
32    pub fn get_delay_functor_manager(&self) -> *mut SKSEDelayFunctorManager {
33        unsafe { (self.0.GetDelayFunctorManager)() }
34    }
35
36    #[inline]
37    pub fn get_object_registry(&self) -> *mut SKSEObjectRegistry {
38        unsafe { (self.0.GetObjectRegistry)() }
39    }
40
41    #[inline]
42    pub fn get_persistent_object_storage(&self) -> *mut SKSEPersistentObjectStorage {
43        unsafe { (self.0.GetPersistentObjectStorage)() }
44    }
45}