pub struct SdkCall<'scope> { /* private fields */ }Expand description
Capabilities available during one direct call from the game.
The lifetime is higher-ranked by the constructors in this module, so a scope cannot be returned, stored, or moved into another thread by safe code.
SdkCall is deliberately neither Send nor Sync:
use scs_sdk::SdkCall;
fn assert_send<T: Send>() {}
fn assert_sync<T: Sync>() {}
assert_send::<SdkCall<'static>>();
assert_sync::<SdkCall<'static>>();Implementations§
Source§impl SdkCall<'_>
impl SdkCall<'_>
Sourcepub const fn telemetry_api_version(&self) -> TelemetryApiVersion
pub const fn telemetry_api_version(&self) -> TelemetryApiVersion
Telemetry API version negotiated for the current plugin session.
The value travels with the copied function table, so upper layers do not need a second runtime field which could drift from the adapter that produced this call capability.
pub const fn logger(&self) -> ScopedLogger<'_>
Sourcepub unsafe fn register_event(
&self,
event: Event,
callback: ScsTelemetryEventCallback,
context: *mut c_void,
) -> SdkResult
pub unsafe fn register_event( &self, event: Event, callback: ScsTelemetryEventCallback, context: *mut c_void, ) -> SdkResult
Registers an SDK event callback.
§Safety
callback must implement the exact SDK ABI, must uphold the validity
requirements for the event-specific event_info pointer, and must not
unwind across the ABI boundary. context must remain valid for every
callback invocation. This method must be called from initialization or
an SCS event callback other than the callback for event, never from a
worker thread or a channel callback.
§Errors
Returns the result reported by the game’s registration function.
Sourcepub unsafe fn unregister_event(&self, event: Event) -> SdkResult
pub unsafe fn unregister_event(&self, event: Event) -> SdkResult
Unregisters an SDK event callback.
§Safety
Must be called from initialization, shutdown, or an SCS event callback. Context storage associated with the old registration must remain alive until this function succeeds and no invocation of that callback is active.
§Errors
Returns the result reported by the game’s unregistration function.
Source§impl SdkCall<'_>
impl SdkCall<'_>
Sourcepub unsafe fn register_channel<T: ChannelValue>(
&self,
channel: Channel<T>,
index: Option<SdkIndex>,
flags: ChannelFlags,
callback: ScsTelemetryChannelCallback,
context: *mut c_void,
) -> SdkResult
pub unsafe fn register_channel<T: ChannelValue>( &self, channel: Channel<T>, index: Option<SdkIndex>, flags: ChannelFlags, callback: ScsTelemetryChannelCallback, context: *mut c_void, ) -> SdkResult
Registers a typed telemetry channel callback.
§Safety
callback must implement the exact SDK ABI, must decode the value
according to T, and must not unwind across the ABI boundary. context
must remain valid for every invocation of callback. This method must
be called from initialization or an SCS event callback, never from a
worker thread or another channel callback.
§Errors
Returns the result reported by the game’s registration function.
Sourcepub unsafe fn unregister_channel<T: ChannelValue>(
&self,
channel: Channel<T>,
index: Option<SdkIndex>,
) -> SdkResult
pub unsafe fn unregister_channel<T: ChannelValue>( &self, channel: Channel<T>, index: Option<SdkIndex>, ) -> SdkResult
Unregisters a telemetry channel callback.
§Safety
Must be called from initialization, shutdown, or an SCS event callback, never from a channel callback or a worker thread. Context storage associated with the old registration must remain alive until this function succeeds and no invocation of that callback is active.
§Errors
Returns the result reported by the game’s unregistration function.
Sourcepub unsafe fn register_erased_channel(
&self,
name: &CStr,
index: Option<SdkIndex>,
value_type: ValueType,
flags: ChannelFlags,
callback: ScsTelemetryChannelCallback,
context: *mut c_void,
) -> SdkResult
pub unsafe fn register_erased_channel( &self, name: &CStr, index: Option<SdkIndex>, value_type: ValueType, flags: ChannelFlags, callback: ScsTelemetryChannelCallback, context: *mut c_void, ) -> SdkResult
Registers a channel whose Rust marker type has been erased by a framework subscription table.
Unlike SdkCall::register_channel, the channel name may be owned by
the caller. This is required for multi-trailer names such as
trailer.3.connected, which do not exist as static macros in the C
header.
§Safety
callback must implement the exact SDK ABI, verify every received value
against value_type, and prevent unwinding across the ABI boundary.
name and context must remain valid for the complete registration
lifetime. This method may only be called at an SDK-approved registration
point on the game main thread.
§Errors
Returns the exact result reported by the game’s registration function.
Sourcepub unsafe fn unregister_erased_channel(
&self,
name: &CStr,
index: Option<SdkIndex>,
value_type: ValueType,
) -> SdkResult
pub unsafe fn unregister_erased_channel( &self, name: &CStr, index: Option<SdkIndex>, value_type: ValueType, ) -> SdkResult
Unregisters one previously registered type-erased channel.
§Safety
This must run at an SDK-approved unregistration point on the game main thread. The callback context and channel name must remain alive until unregistration succeeds and any active callback has returned.
§Errors
Returns the exact result reported by the game’s unregistration function.