Skip to main content

SdkCall

Struct SdkCall 

Source
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<'_>

Source

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.

Source

pub const fn logger(&self) -> ScopedLogger<'_>

Source

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.

Source

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<'_>

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'scope> !Send for SdkCall<'scope>

§

impl<'scope> !Sync for SdkCall<'scope>

§

impl<'scope> !UnwindSafe for SdkCall<'scope>

§

impl<'scope> Freeze for SdkCall<'scope>

§

impl<'scope> RefUnwindSafe for SdkCall<'scope>

§

impl<'scope> Unpin for SdkCall<'scope>

§

impl<'scope> UnsafeUnpin for SdkCall<'scope>

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

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.