Struct Device

Source
pub struct Device;
Expand description

This class describes the device that is running this application! It contains identifiers, capabilities, and a few adjustable settings here and there. https://stereokit.net/Pages/StereoKit/Device.html

§Examples

use stereokit_rust::{util::{Device, DisplayType, DeviceTracking}, sk::DisplayBlend};

// These are the expected results for tests on a PC:
let display_type = Device::get_display_type();
assert_eq!(display_type, DisplayType::Flatscreen);

let display_blend = Device::get_display_blend();
assert_eq!(display_blend, DisplayBlend::Opaque);

let device_tracking = Device::get_tracking();
assert_eq!(device_tracking, DeviceTracking::None);

let device_name = Device::get_name().unwrap();
assert_eq!(device_name, "Offscreen");

let device_runtime = Device::get_runtime().unwrap();
assert_eq!(device_runtime, "None");

let device_gpu = Device::get_gpu().unwrap();
assert_ne!(device_gpu, "Name of your GPU");

assert_eq!(Device::has_eye_gaze(), false);
assert_eq!(Device::has_hand_tracking(), false);

assert_eq!(Device::valid_blend(DisplayBlend::None), false);
assert_eq!(Device::display_blend(DisplayBlend::None), false);

Implementations§

Source§

impl Device

Source

pub fn display_blend(blend: DisplayBlend) -> bool

Allows you to set and get the current blend mode of the device! Setting this may not succeed if the blend mode is not valid. https://stereokit.net/Pages/StereoKit/Device/DisplayBlend.html

see also device_display_set_blend

§Examples
use stereokit_rust::{util::Device, sk::DisplayBlend};

// These are the expected results for tests on a PC:
assert_eq!(Device::get_display_blend(), DisplayBlend::Opaque);

assert_eq!(Device::display_blend(DisplayBlend::AnyTransparent), false);
assert_eq!(Device::display_blend(DisplayBlend::None), false);
assert_eq!(Device::display_blend(DisplayBlend::Additive), false);
Source

pub fn get_display_blend() -> DisplayBlend

Allows you to set and get the current blend mode of the device! Setting this may not succeed if the blend mode is not valid. https://stereokit.net/Pages/StereoKit/Device/DisplayBlend.html

see also device_display_get_blend see example in Device::display_blend

Source

pub fn get_display_type() -> DisplayType

What type of display is this? Most XR headsets will report stereo, but the Simulator will report flatscreen. https://stereokit.net/Pages/StereoKit/Device/DisplayType.html

see also device_display_get_type

§Examples
use stereokit_rust::util::{Device, DisplayType};

// These are the expected results for tests on a PC:
assert_eq!(Device::get_display_type(), DisplayType::Flatscreen);
Source

pub fn get_runtime<'a>() -> Result<&'a str, StereoKitError>

This is the name of the OpenXR runtime that powers the current device! This can help you determine which implementation quirks to expect based on the codebase used. On the simulator, this will be “Simulator”, and in other non-XR modes this will be “None”. https://stereokit.net/Pages/StereoKit/Device/Runtime.html

see also device_get_runtime

§Examples
use stereokit_rust::util::Device;

// These are the expected results for tests on a PC:
assert_eq!(Device::get_runtime().unwrap(), "None");
Source

pub fn get_gpu<'a>() -> Result<&'a str, StereoKitError>

The reported name of the GPU, this will differ between D3D and GL. https://stereokit.net/Pages/StereoKit/Device/GPU.html

see also device_get_gpu

Source

pub fn has_eye_gaze() -> bool

Does the device we’re on have eye tracking support present for input purposes? This is not an indicator that the user has given the application permission to access this information. See Input.Gaze for how to use this data. https://stereokit.net/Pages/StereoKit/Device/HasEyeGaze.html

see also device_has_eye_gaze

§Examples
use stereokit_rust::util::Device;

// These are the expected results for tests on a PC:
assert_eq!(Device::has_eye_gaze(), false);
Source

pub fn has_hand_tracking() -> bool

Tells if the device is capable of tracking hands. This does not tell if the user is actually using their hands for input, merely that it’s possible to! https://stereokit.net/Pages/StereoKit/Device/HasHandTracking.html

see also device_has_hand_tracking

§Examples
use stereokit_rust::util::Device;

// These are the expected results for tests on a PC:
assert_eq!(Device::has_hand_tracking(), false);
Source

pub fn get_name<'a>() -> Result<&'a str, StereoKitError>

This is the name of the active device! From OpenXR, this is the same as systemName from XrSystemProperties. The simulator will say “Simulator”. https://stereokit.net/Pages/StereoKit/Device/Name.html

see also device_get_name

§Examples
use stereokit_rust::util::Device;

// These are the expected results for tests on a PC:
assert_eq!(Device::get_name().unwrap(), "Offscreen");
Source

pub fn get_tracking() -> DeviceTracking

The tracking capabilities of this device! Is it 3DoF, rotation only? Or is it 6DoF, with positional tracking as well? Maybe it can’t track at all! https://stereokit.net/Pages/StereoKit/Device/Tracking.html

see also device_get_tracking

§Examples
use stereokit_rust::util::{Device, DeviceTracking};

// These are the expected results for tests on a PC:
assert_eq!(Device::get_tracking(), DeviceTracking::None);
Source

pub fn valid_blend(blend: DisplayBlend) -> bool

Tells if a particular blend mode is valid on this device. Some devices may be capable of more than one blend mode. https://stereokit.net/Pages/StereoKit/Device/ValidBlend.html

see also device_display_valid_blend

§Examples
use stereokit_rust::{util::Device, sk::DisplayBlend};

// These are the expected results for tests on a PC:
assert_eq!(Device::valid_blend(DisplayBlend::Opaque), true);
assert_eq!(Device::valid_blend(DisplayBlend::None), false);
assert_eq!(Device::valid_blend(DisplayBlend::Additive), false);
assert_eq!(Device::valid_blend(DisplayBlend::Blend), false);
assert_eq!(Device::valid_blend(DisplayBlend::AnyTransparent), false);

Auto Trait Implementations§

§

impl Freeze for Device

§

impl RefUnwindSafe for Device

§

impl Send for Device

§

impl Sync for Device

§

impl Unpin for Device

§

impl UnwindSafe for Device

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more