neuromorphic_types/
lib.rs1pub trait SliceView {
2 fn as_bytes(&self) -> &[u8]
3 where
4 Self: Sized,
5 {
6 unsafe {
7 std::slice::from_raw_parts(
8 (self as *const Self) as *const u8,
9 std::mem::size_of::<Self>(),
10 )
11 }
12 }
13}
14
15#[repr(u8)]
16#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
17pub enum Polarity {
18 Off = 0,
19 On = 1,
20}
21impl SliceView for Polarity {}
22
23#[repr(C, packed)]
24#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
25pub struct PolarityEvent<Timestamp, X, Y> {
26 pub t: Timestamp,
27 pub x: X,
28 pub y: Y,
29 pub polarity: Polarity,
30}
31impl<Timestamp, X, Y> SliceView for PolarityEvent<Timestamp, X, Y> {}
32
33#[repr(u8)]
34#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
35pub enum AtisPolarity {
36 Off = 0,
37 On = 1,
38 ExposureStart = 2,
39 ExposureEnd = 3,
40}
41impl SliceView for AtisPolarity {}
42
43#[repr(C, packed)]
44#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
45pub struct AtisEvent<Timestamp, X, Y> {
46 pub t: Timestamp,
47 pub x: X,
48 pub y: Y,
49 pub polarity: AtisPolarity,
50}
51impl<Timestamp, X, Y> SliceView for AtisEvent<Timestamp, X, Y> {}
52
53#[repr(u8)]
54#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
55pub enum TriggerPolarity {
56 Falling = 0,
57 Rising = 1,
58 Pulse = 2,
59}
60impl SliceView for TriggerPolarity {}
61
62#[repr(C, packed)]
63#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
64pub struct TriggerEvent<Timestamp, Id> {
65 pub t: Timestamp,
66 pub id: Id,
67 pub polarity: TriggerPolarity,
68}
69impl<Timestamp, Id> SliceView for TriggerEvent<Timestamp, Id> {}