Skip to main content

pawkit_input/
lib.rs

1#![allow(incomplete_features)]
2#![feature(decl_macro, variant_count, generic_const_exprs)]
3
4use std::ops::Deref;
5
6use pawkit_crockford::Ulid;
7use pawkit_interner::InternString;
8use serde::{Deserialize, Serialize};
9
10pub mod binding;
11pub mod manager;
12pub mod state;
13
14#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
15#[serde(transparent)]
16pub struct BindingName(InternString);
17
18#[repr(C)]
19#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
20pub struct DeviceId(Ulid);
21
22impl BindingName {
23    pub fn new(name: &str) -> Self {
24        return Self(InternString::new(name));
25    }
26}
27
28impl Deref for BindingName {
29    type Target = InternString;
30
31    fn deref(&self) -> &Self::Target {
32        return &self.0;
33    }
34}
35
36impl DeviceId {
37    pub fn null() -> Self {
38        return Self(Ulid::from_raw_parts(0, 0));
39    }
40}
41
42fn length_squared([a, b]: [f32; 2]) -> f32 {
43    return a * a + b * b;
44}