Skip to main content

GnsUtils

Struct GnsUtils 

Source
pub struct GnsUtils(/* private fields */);

Implementations§

Source§

impl GnsUtils

Source

pub fn enable_debug_output( &self, ty: ESteamNetworkingSocketsDebugOutputType, f: impl Fn(ESteamNetworkingSocketsDebugOutputType, &str) + Send + Sync + 'static, )

Installs a debug callback.

Only the first call takes effect. Later calls are ignored.

GameNetworkingSockets runs the callback on its service thread, which is why the callback must be Send + Sync + 'static. The callback may capture state, because the wrapper stores it as a boxed closure. The &str is borrowed only for the duration of the call.

Source

pub fn allocate_message<P: Payload>( &self, conn: GnsConnection, flags: SendFlags, payload: P, ) -> GnsNetworkMessage<ToSend>

Allocates an outbound message and takes ownership of payload.

The buffer stays alive until GameNetworkingSockets releases the message. At that point the wrapper rebuilds P with Payload::from_raw and drops it. Nothing is copied when the payload already owns heap memory.

Source

pub fn set_global_config_value( &self, typ: ESteamNetworkingConfigValue, value: GnsConfig<'_>, ) -> GnsResult<()>

Sets a global configuration value, for example k_ESteamNetworkingConfig_FakePacketLag_Send to 1000 ms.

Source

pub fn set_connection_config_value( &self, conn: GnsConnection, typ: ESteamNetworkingConfigValue, value: GnsConfig<'_>, ) -> GnsResult<()>

Sets a configuration value on one connection, for example k_ESteamNetworkingConfig_SendRateMin on an accepted connection.

Source

pub fn get_global_config_value( &self, typ: ESteamNetworkingConfigValue, ) -> GnsResult<GnsConfigValue>

Reads a global configuration value back, the counterpart of Self::set_global_config_value.

Source

pub fn get_connection_config_value( &self, conn: GnsConnection, typ: ESteamNetworkingConfigValue, ) -> GnsResult<GnsConfigValue>

Reads a configuration value from one connection, the counterpart of Self::set_connection_config_value.

A value that was never set on the connection itself comes back from the enclosing scope, such as the listen socket or the global defaults.

Source

pub fn get_config_value_info( &self, typ: ESteamNetworkingConfigValue, ) -> Option<(&'static str, ESteamNetworkingConfigDataType, ESteamNetworkingConfigScope)>

Returns the name, data type, and maximally specific scope of a configuration value, or None if the value is unknown.

Source

pub fn local_timestamp(&self) -> SteamNetworkingMicroseconds

Returns the current local timestamp, in microseconds.

The timebase starts at a value that will never be confused with an interval, and it matches GnsNetworkMessage::time_received.

Auto Trait Implementations§

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 = !

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.