pub struct Bindings<T: BindingTypes> { /* private fields */ }Expand description
Used for saving and loading input settings.
An action can either be a single button or a combination of them.
§Examples
Example Ron config file:
(
axes: {
"updown": Emulated(
pos: Key(Up),
neg: Key(Down)
),
"leftright": Multiple([ // Multiple bindings for one axis
Emulated(
pos: Key(Right),
neg: Key(Left)
),
Emulated(
pos: Key(D),
neg: Key(A)
)
])
},
actions: {
"fire": [ [Mouse(Left)], [Key(X)] ], // Multiple bindings for one action
"reload": [ [Key(LControl), Key(R)] ] // Combinations of multiple bindings possible
}
)Implementations§
Source§impl<T: BindingTypes> Bindings<T>
impl<T: BindingTypes> Bindings<T>
Source§impl<T: BindingTypes> Bindings<T>
impl<T: BindingTypes> Bindings<T>
Sourcepub fn insert_axis<A: Into<T::Axis>>(
&mut self,
id: A,
axis: Axis,
) -> Result<Option<Axis>, BindingError<T>>
pub fn insert_axis<A: Into<T::Axis>>( &mut self, id: A, axis: Axis, ) -> Result<Option<Axis>, BindingError<T>>
Assign an axis to an ID value
This will insert a new axis if no entry for this id exists. If one does exist this will replace the axis at that id and return it.
Sourcepub fn remove_axis<A>(&mut self, id: &A) -> Option<Axis>
pub fn remove_axis<A>(&mut self, id: &A) -> Option<Axis>
Removes an axis, this will return the removed axis if successful.
Sourcepub fn insert_action_binding<B: IntoIterator<Item = Button>>(
&mut self,
id: T::Action,
binding: B,
) -> Result<(), BindingError<T>>
pub fn insert_action_binding<B: IntoIterator<Item = Button>>( &mut self, id: T::Action, binding: B, ) -> Result<(), BindingError<T>>
Add a button or button combination to an action.
This will attempt to insert a new binding between this action and the button(s).
Sourcepub fn remove_action_binding<A>(
&mut self,
id: &A,
binding: &[Button],
) -> Result<(), ActionRemovedError>
pub fn remove_action_binding<A>( &mut self, id: &A, binding: &[Button], ) -> Result<(), ActionRemovedError>
Removes an action binding that was assigned previously.
Sourcepub fn action_bindings<A>(&self, id: &A) -> impl Iterator<Item = &[Button]>
pub fn action_bindings<A>(&self, id: &A) -> impl Iterator<Item = &[Button]>
Returns an action’s bindings.
Sourcepub fn check_invariants(&mut self) -> Result<(), BindingError<T>>
pub fn check_invariants(&mut self) -> Result<(), BindingError<T>>
Check that this structure upholds its guarantees. Should only be necessary when serializing or deserializing the bindings.
Trait Implementations§
Source§impl<T: BindingTypes> Clone for Bindings<T>
impl<T: BindingTypes> Clone for Bindings<T>
Source§impl<T: BindingTypes> Debug for Bindings<T>
impl<T: BindingTypes> Debug for Bindings<T>
Source§impl<T: BindingTypes> Default for Bindings<T>
impl<T: BindingTypes> Default for Bindings<T>
Source§impl<'de, T: BindingTypes> Deserialize<'de> for Bindings<T>
impl<'de, T: BindingTypes> Deserialize<'de> for Bindings<T>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<T> Freeze for Bindings<T>
impl<T> RefUnwindSafe for Bindings<T>
impl<T> Send for Bindings<T>
impl<T> Sync for Bindings<T>
impl<T> Unpin for Bindings<T>
impl<T> UnsafeUnpin for Bindings<T>
impl<T> UnwindSafe for Bindings<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Config for Twhere
T: for<'a> Deserialize<'a> + Serialize,
impl<T> Config for Twhere
T: for<'a> Deserialize<'a> + Serialize,
Source§fn load<P>(path: P) -> Result<T, ConfigError>
fn load<P>(path: P) -> Result<T, ConfigError>
Loads a configuration structure from a file.
Source§fn load_bytes(bytes: &[u8]) -> Result<T, ConfigError>
fn load_bytes(bytes: &[u8]) -> Result<T, ConfigError>
Loads configuration structure from raw bytes.
Source§fn write<P>(&self, path: P) -> Result<(), ConfigError>
fn write<P>(&self, path: P) -> Result<(), ConfigError>
Writes a configuration structure to a file.
Source§fn load_no_fallback<P>(path: P) -> Result<Self, ConfigError>
fn load_no_fallback<P>(path: P) -> Result<Self, ConfigError>
👎Deprecated:
use load instead
Loads a configuration structure from a file.
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SetParameter for T
impl<T> SetParameter for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<T> TryDefault for Twhere
T: Default,
impl<T> TryDefault for Twhere
T: Default,
Source§fn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
Tries to create the default.
Source§fn unwrap_default() -> Self
fn unwrap_default() -> Self
Calls
try_default and panics on an error case.