use crate::prelude::*; pub trait EntryTrait { /// Return currently available extensions fn available_extensions(&self) -> Result; /// Create an [Instance] with the enabled extensions. fn create_instance(&self, exts: ExtensionSet) -> Result; } pub trait InstanceTrait { /// Returns the [Entry] used to create this. fn entry(&self) -> Entry; /// Returns an [ExtensionSet] listing all enabled extensions. fn enabled_extensions(&self) -> ExtensionSet; /// Creates a [Session] with the requested properties fn create_session(&self, info: SessionCreateInfo) -> Result; } pub trait SessionTrait { /// Returns the [Instance] used to create this. fn instance(&self) -> &Instance; /// Request input modules with the specified bindings. fn create_input(&self, bindings: Bindings) -> Result; /// Blocks until a rendering frame is available and then begins it. fn begin_frame(&self) -> Result<()>; /// Submits rendering work for this frame. fn end_frame(&self) -> Result<()>; } pub trait InputTrait { fn get_haptics(&self, path: ActionId) -> Result>; fn get_pose(&self, path: ActionId) -> Result>; fn get_float(&self, path: ActionId) -> Result>; fn get_bool(&self, path: ActionId) -> Result>; } pub trait ActionTrait { fn id(&self) -> ActionId; } pub trait ActionInputTrait {} pub trait HapticTrait {} impl EntryTrait for T { fn available_extensions(&self) -> Result { self.entry().available_extensions() } fn create_instance(&self, exts: ExtensionSet) -> Result { self.entry().create_instance(exts) } } impl InstanceTrait for T { fn entry(&self) -> Entry { self.instance().entry() } fn enabled_extensions(&self) -> ExtensionSet { self.instance().enabled_extensions() } fn create_session(&self, info: SessionCreateInfo) -> Result { self.instance().create_session(info) } }