aedat 1.3.3

A fast AEDAT4 Rust implementation. Forked from https://github.com/neuromorphicsystems/aedat, a Rust AEDAT4 decoder for Python projects.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
// automatically generated by the FlatBuffers compiler, do not modify

use std::cmp::Ordering;
use std::mem;

extern crate flatbuffers;
use self::flatbuffers::{EndianScalar, Follow};

pub enum ImuOffset {}
#[derive(Copy, Clone, PartialEq)]

pub struct Imu<'a> {
    pub _tab: flatbuffers::Table<'a>,
}

impl<'a> flatbuffers::Follow<'a> for Imu<'a> {
    type Inner = Imu<'a>;
    #[inline]
    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
        Self {
            _tab: flatbuffers::Table { buf, loc },
        }
    }
}

impl<'a> Imu<'a> {
    #[inline]
    pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
        Imu { _tab: table }
    }
    #[allow(unused_mut)]
    pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
        _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
        args: &'args ImuArgs,
    ) -> flatbuffers::WIPOffset<Imu<'bldr>> {
        let mut builder = ImuBuilder::new(_fbb);
        builder.add_t(args.t);
        builder.add_magnetometer_z(args.magnetometer_z);
        builder.add_magnetometer_y(args.magnetometer_y);
        builder.add_magnetometer_x(args.magnetometer_x);
        builder.add_gyroscope_z(args.gyroscope_z);
        builder.add_gyroscope_y(args.gyroscope_y);
        builder.add_gyroscope_x(args.gyroscope_x);
        builder.add_accelerometer_z(args.accelerometer_z);
        builder.add_accelerometer_y(args.accelerometer_y);
        builder.add_accelerometer_x(args.accelerometer_x);
        builder.add_temperature(args.temperature);
        builder.finish()
    }

    pub const VT_T: flatbuffers::VOffsetT = 4;
    pub const VT_TEMPERATURE: flatbuffers::VOffsetT = 6;
    pub const VT_ACCELEROMETER_X: flatbuffers::VOffsetT = 8;
    pub const VT_ACCELEROMETER_Y: flatbuffers::VOffsetT = 10;
    pub const VT_ACCELEROMETER_Z: flatbuffers::VOffsetT = 12;
    pub const VT_GYROSCOPE_X: flatbuffers::VOffsetT = 14;
    pub const VT_GYROSCOPE_Y: flatbuffers::VOffsetT = 16;
    pub const VT_GYROSCOPE_Z: flatbuffers::VOffsetT = 18;
    pub const VT_MAGNETOMETER_X: flatbuffers::VOffsetT = 20;
    pub const VT_MAGNETOMETER_Y: flatbuffers::VOffsetT = 22;
    pub const VT_MAGNETOMETER_Z: flatbuffers::VOffsetT = 24;

    #[inline]
    pub fn t(&self) -> i64 {
        self._tab.get::<i64>(Imu::VT_T, Some(0)).unwrap()
    }
    #[inline]
    pub fn temperature(&self) -> f32 {
        self._tab
            .get::<f32>(Imu::VT_TEMPERATURE, Some(0.0))
            .unwrap()
    }
    #[inline]
    pub fn accelerometer_x(&self) -> f32 {
        self._tab
            .get::<f32>(Imu::VT_ACCELEROMETER_X, Some(0.0))
            .unwrap()
    }
    #[inline]
    pub fn accelerometer_y(&self) -> f32 {
        self._tab
            .get::<f32>(Imu::VT_ACCELEROMETER_Y, Some(0.0))
            .unwrap()
    }
    #[inline]
    pub fn accelerometer_z(&self) -> f32 {
        self._tab
            .get::<f32>(Imu::VT_ACCELEROMETER_Z, Some(0.0))
            .unwrap()
    }
    #[inline]
    pub fn gyroscope_x(&self) -> f32 {
        self._tab
            .get::<f32>(Imu::VT_GYROSCOPE_X, Some(0.0))
            .unwrap()
    }
    #[inline]
    pub fn gyroscope_y(&self) -> f32 {
        self._tab
            .get::<f32>(Imu::VT_GYROSCOPE_Y, Some(0.0))
            .unwrap()
    }
    #[inline]
    pub fn gyroscope_z(&self) -> f32 {
        self._tab
            .get::<f32>(Imu::VT_GYROSCOPE_Z, Some(0.0))
            .unwrap()
    }
    #[inline]
    pub fn magnetometer_x(&self) -> f32 {
        self._tab
            .get::<f32>(Imu::VT_MAGNETOMETER_X, Some(0.0))
            .unwrap()
    }
    #[inline]
    pub fn magnetometer_y(&self) -> f32 {
        self._tab
            .get::<f32>(Imu::VT_MAGNETOMETER_Y, Some(0.0))
            .unwrap()
    }
    #[inline]
    pub fn magnetometer_z(&self) -> f32 {
        self._tab
            .get::<f32>(Imu::VT_MAGNETOMETER_Z, Some(0.0))
            .unwrap()
    }
}

impl flatbuffers::Verifiable for Imu<'_> {
    #[inline]
    fn run_verifier(
        v: &mut flatbuffers::Verifier,
        pos: usize,
    ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
        use self::flatbuffers::Verifiable;
        v.visit_table(pos)?
            .visit_field::<i64>(&"t", Self::VT_T, false)?
            .visit_field::<f32>(&"temperature", Self::VT_TEMPERATURE, false)?
            .visit_field::<f32>(&"accelerometer_x", Self::VT_ACCELEROMETER_X, false)?
            .visit_field::<f32>(&"accelerometer_y", Self::VT_ACCELEROMETER_Y, false)?
            .visit_field::<f32>(&"accelerometer_z", Self::VT_ACCELEROMETER_Z, false)?
            .visit_field::<f32>(&"gyroscope_x", Self::VT_GYROSCOPE_X, false)?
            .visit_field::<f32>(&"gyroscope_y", Self::VT_GYROSCOPE_Y, false)?
            .visit_field::<f32>(&"gyroscope_z", Self::VT_GYROSCOPE_Z, false)?
            .visit_field::<f32>(&"magnetometer_x", Self::VT_MAGNETOMETER_X, false)?
            .visit_field::<f32>(&"magnetometer_y", Self::VT_MAGNETOMETER_Y, false)?
            .visit_field::<f32>(&"magnetometer_z", Self::VT_MAGNETOMETER_Z, false)?
            .finish();
        Ok(())
    }
}
pub struct ImuArgs {
    pub t: i64,
    pub temperature: f32,
    pub accelerometer_x: f32,
    pub accelerometer_y: f32,
    pub accelerometer_z: f32,
    pub gyroscope_x: f32,
    pub gyroscope_y: f32,
    pub gyroscope_z: f32,
    pub magnetometer_x: f32,
    pub magnetometer_y: f32,
    pub magnetometer_z: f32,
}
impl<'a> Default for ImuArgs {
    #[inline]
    fn default() -> Self {
        ImuArgs {
            t: 0,
            temperature: 0.0,
            accelerometer_x: 0.0,
            accelerometer_y: 0.0,
            accelerometer_z: 0.0,
            gyroscope_x: 0.0,
            gyroscope_y: 0.0,
            gyroscope_z: 0.0,
            magnetometer_x: 0.0,
            magnetometer_y: 0.0,
            magnetometer_z: 0.0,
        }
    }
}
pub struct ImuBuilder<'a: 'b, 'b> {
    fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b> ImuBuilder<'a, 'b> {
    #[inline]
    pub fn add_t(&mut self, t: i64) {
        self.fbb_.push_slot::<i64>(Imu::VT_T, t, 0);
    }
    #[inline]
    pub fn add_temperature(&mut self, temperature: f32) {
        self.fbb_
            .push_slot::<f32>(Imu::VT_TEMPERATURE, temperature, 0.0);
    }
    #[inline]
    pub fn add_accelerometer_x(&mut self, accelerometer_x: f32) {
        self.fbb_
            .push_slot::<f32>(Imu::VT_ACCELEROMETER_X, accelerometer_x, 0.0);
    }
    #[inline]
    pub fn add_accelerometer_y(&mut self, accelerometer_y: f32) {
        self.fbb_
            .push_slot::<f32>(Imu::VT_ACCELEROMETER_Y, accelerometer_y, 0.0);
    }
    #[inline]
    pub fn add_accelerometer_z(&mut self, accelerometer_z: f32) {
        self.fbb_
            .push_slot::<f32>(Imu::VT_ACCELEROMETER_Z, accelerometer_z, 0.0);
    }
    #[inline]
    pub fn add_gyroscope_x(&mut self, gyroscope_x: f32) {
        self.fbb_
            .push_slot::<f32>(Imu::VT_GYROSCOPE_X, gyroscope_x, 0.0);
    }
    #[inline]
    pub fn add_gyroscope_y(&mut self, gyroscope_y: f32) {
        self.fbb_
            .push_slot::<f32>(Imu::VT_GYROSCOPE_Y, gyroscope_y, 0.0);
    }
    #[inline]
    pub fn add_gyroscope_z(&mut self, gyroscope_z: f32) {
        self.fbb_
            .push_slot::<f32>(Imu::VT_GYROSCOPE_Z, gyroscope_z, 0.0);
    }
    #[inline]
    pub fn add_magnetometer_x(&mut self, magnetometer_x: f32) {
        self.fbb_
            .push_slot::<f32>(Imu::VT_MAGNETOMETER_X, magnetometer_x, 0.0);
    }
    #[inline]
    pub fn add_magnetometer_y(&mut self, magnetometer_y: f32) {
        self.fbb_
            .push_slot::<f32>(Imu::VT_MAGNETOMETER_Y, magnetometer_y, 0.0);
    }
    #[inline]
    pub fn add_magnetometer_z(&mut self, magnetometer_z: f32) {
        self.fbb_
            .push_slot::<f32>(Imu::VT_MAGNETOMETER_Z, magnetometer_z, 0.0);
    }
    #[inline]
    pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ImuBuilder<'a, 'b> {
        let start = _fbb.start_table();
        ImuBuilder {
            fbb_: _fbb,
            start_: start,
        }
    }
    #[inline]
    pub fn finish(self) -> flatbuffers::WIPOffset<Imu<'a>> {
        let o = self.fbb_.end_table(self.start_);
        flatbuffers::WIPOffset::new(o.value())
    }
}

impl std::fmt::Debug for Imu<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let mut ds = f.debug_struct("Imu");
        ds.field("t", &self.t());
        ds.field("temperature", &self.temperature());
        ds.field("accelerometer_x", &self.accelerometer_x());
        ds.field("accelerometer_y", &self.accelerometer_y());
        ds.field("accelerometer_z", &self.accelerometer_z());
        ds.field("gyroscope_x", &self.gyroscope_x());
        ds.field("gyroscope_y", &self.gyroscope_y());
        ds.field("gyroscope_z", &self.gyroscope_z());
        ds.field("magnetometer_x", &self.magnetometer_x());
        ds.field("magnetometer_y", &self.magnetometer_y());
        ds.field("magnetometer_z", &self.magnetometer_z());
        ds.finish()
    }
}
pub enum ImuPacketOffset {}
#[derive(Copy, Clone, PartialEq)]

pub struct ImuPacket<'a> {
    pub _tab: flatbuffers::Table<'a>,
}

impl<'a> flatbuffers::Follow<'a> for ImuPacket<'a> {
    type Inner = ImuPacket<'a>;
    #[inline]
    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
        Self {
            _tab: flatbuffers::Table { buf, loc },
        }
    }
}

impl<'a> ImuPacket<'a> {
    #[inline]
    pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
        ImuPacket { _tab: table }
    }
    #[allow(unused_mut)]
    pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
        _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
        args: &'args ImuPacketArgs<'args>,
    ) -> flatbuffers::WIPOffset<ImuPacket<'bldr>> {
        let mut builder = ImuPacketBuilder::new(_fbb);
        if let Some(x) = args.elements {
            builder.add_elements(x);
        }
        builder.finish()
    }

    pub const VT_ELEMENTS: flatbuffers::VOffsetT = 4;

    #[inline]
    pub fn elements(
        &self,
    ) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Imu<'a>>>> {
        self._tab.get::<flatbuffers::ForwardsUOffset<
            flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Imu>>,
        >>(ImuPacket::VT_ELEMENTS, None)
    }
}

impl flatbuffers::Verifiable for ImuPacket<'_> {
    #[inline]
    fn run_verifier(
        v: &mut flatbuffers::Verifier,
        pos: usize,
    ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
        use self::flatbuffers::Verifiable;
        v.visit_table(pos)?
            .visit_field::<flatbuffers::ForwardsUOffset<
                flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<Imu>>,
            >>(&"elements", Self::VT_ELEMENTS, false)?
            .finish();
        Ok(())
    }
}
pub struct ImuPacketArgs<'a> {
    pub elements: Option<
        flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Imu<'a>>>>,
    >,
}
impl<'a> Default for ImuPacketArgs<'a> {
    #[inline]
    fn default() -> Self {
        ImuPacketArgs { elements: None }
    }
}
pub struct ImuPacketBuilder<'a: 'b, 'b> {
    fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b> ImuPacketBuilder<'a, 'b> {
    #[inline]
    pub fn add_elements(
        &mut self,
        elements: flatbuffers::WIPOffset<
            flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<Imu<'b>>>,
        >,
    ) {
        self.fbb_
            .push_slot_always::<flatbuffers::WIPOffset<_>>(ImuPacket::VT_ELEMENTS, elements);
    }
    #[inline]
    pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ImuPacketBuilder<'a, 'b> {
        let start = _fbb.start_table();
        ImuPacketBuilder {
            fbb_: _fbb,
            start_: start,
        }
    }
    #[inline]
    pub fn finish(self) -> flatbuffers::WIPOffset<ImuPacket<'a>> {
        let o = self.fbb_.end_table(self.start_);
        flatbuffers::WIPOffset::new(o.value())
    }
}

impl std::fmt::Debug for ImuPacket<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let mut ds = f.debug_struct("ImuPacket");
        ds.field("elements", &self.elements());
        ds.finish()
    }
}
#[inline]
#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")]
pub fn get_root_as_imu_packet<'a>(buf: &'a [u8]) -> ImuPacket<'a> {
    unsafe { flatbuffers::root_unchecked::<ImuPacket<'a>>(buf) }
}

#[inline]
#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")]
pub fn get_size_prefixed_root_as_imu_packet<'a>(buf: &'a [u8]) -> ImuPacket<'a> {
    unsafe { flatbuffers::size_prefixed_root_unchecked::<ImuPacket<'a>>(buf) }
}

#[inline]
/// Verifies that a buffer of bytes contains a `ImuPacket`
/// and returns it.
/// Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_imu_packet_unchecked`.
pub fn root_as_imu_packet(buf: &[u8]) -> Result<ImuPacket, flatbuffers::InvalidFlatbuffer> {
    flatbuffers::root::<ImuPacket>(buf)
}
#[inline]
/// Verifies that a buffer of bytes contains a size prefixed
/// `ImuPacket` and returns it.
/// Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `size_prefixed_root_as_imu_packet_unchecked`.
pub fn size_prefixed_root_as_imu_packet(
    buf: &[u8],
) -> Result<ImuPacket, flatbuffers::InvalidFlatbuffer> {
    flatbuffers::size_prefixed_root::<ImuPacket>(buf)
}
#[inline]
/// Verifies, with the given options, that a buffer of bytes
/// contains a `ImuPacket` and returns it.
/// Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_imu_packet_unchecked`.
pub fn root_as_imu_packet_with_opts<'b, 'o>(
    opts: &'o flatbuffers::VerifierOptions,
    buf: &'b [u8],
) -> Result<ImuPacket<'b>, flatbuffers::InvalidFlatbuffer> {
    flatbuffers::root_with_opts::<ImuPacket<'b>>(opts, buf)
}
#[inline]
/// Verifies, with the given verifier options, that a buffer of
/// bytes contains a size prefixed `ImuPacket` and returns
/// it. Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_imu_packet_unchecked`.
pub fn size_prefixed_root_as_imu_packet_with_opts<'b, 'o>(
    opts: &'o flatbuffers::VerifierOptions,
    buf: &'b [u8],
) -> Result<ImuPacket<'b>, flatbuffers::InvalidFlatbuffer> {
    flatbuffers::size_prefixed_root_with_opts::<ImuPacket<'b>>(opts, buf)
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a ImuPacket and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `ImuPacket`.
pub unsafe fn root_as_imu_packet_unchecked(buf: &[u8]) -> ImuPacket {
    flatbuffers::root_unchecked::<ImuPacket>(buf)
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed ImuPacket and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `ImuPacket`.
pub unsafe fn size_prefixed_root_as_imu_packet_unchecked(buf: &[u8]) -> ImuPacket {
    flatbuffers::size_prefixed_root_unchecked::<ImuPacket>(buf)
}
pub const IMU_PACKET_IDENTIFIER: &str = "IMUS";

#[inline]
pub fn imu_packet_buffer_has_identifier(buf: &[u8]) -> bool {
    flatbuffers::buffer_has_identifier(buf, IMU_PACKET_IDENTIFIER, false)
}

#[inline]
pub fn imu_packet_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool {
    flatbuffers::buffer_has_identifier(buf, IMU_PACKET_IDENTIFIER, true)
}

#[inline]
pub fn finish_imu_packet_buffer<'a, 'b>(
    fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    root: flatbuffers::WIPOffset<ImuPacket<'a>>,
) {
    fbb.finish(root, Some(IMU_PACKET_IDENTIFIER));
}

#[inline]
pub fn finish_size_prefixed_imu_packet_buffer<'a, 'b>(
    fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    root: flatbuffers::WIPOffset<ImuPacket<'a>>,
) {
    fbb.finish_size_prefixed(root, Some(IMU_PACKET_IDENTIFIER));
}