From 856c8e8986796e604712bb031af3bb54df2314fc Mon Sep 17 00:00:00 2001 From: Alexandre Marcireau Date: Sat, 1 Jun 2024 12:56:47 +1000 Subject: [PATCH] Add support for "p" alias (besides "on") Fixes #16. --- .cargo/config | 5 - .github/workflows/build_wheels.yml | 20 +- Cargo.lock | 295 ++++++------ Cargo.toml | 13 +- pyproject.toml | 4 +- src/events_generated.rs | 490 ++++++++++---------- src/frame_generated.rs | 650 ++++++++++++-------------- src/imus_generated.rs | 717 +++++++++++++---------------- src/ioheader_generated.rs | 406 ++++++++-------- src/lib.rs | 205 ++++++--- src/triggers_generated.rs | 561 +++++++++++----------- test.py | 68 +-- 12 files changed, 1658 insertions(+), 1776 deletions(-) delete mode 100644 .cargo/config diff --git a/.cargo/config b/.cargo/config deleted file mode 100644 index 15d5d32..0000000 --- a/.cargo/config +++ /dev/null @@ -1,5 +0,0 @@ -[target.x86_64-apple-darwin] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index adfc672..54a6efc 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -9,6 +9,7 @@ on: env: CIBW_ARCHS_MACOS: x86_64 arm64 + CIBW_ARCHS_LINUX: x86_64 CIBW_BEFORE_ALL_LINUX: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain=stable --profile=minimal -y CIBW_ENVIRONMENT_LINUX: 'PATH="$HOME/.cargo/bin:$PATH"' CIBW_SKIP: cp36-* cp37-* pp* *i686 @@ -28,9 +29,9 @@ jobs: - run: rustup target add i686-pc-windows-msvc if: startsWith(matrix.os, 'windows') - uses: pypa/cibuildwheel@v2.18.1 - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: wheelhouse + name: wheelhouse-${{ matrix.os }} path: ./wheelhouse/*.whl import_library: name: Import library on ${{ matrix.os }} with Python ${{ matrix.python }} @@ -41,12 +42,12 @@ jobs: python: ["3.8", "3.9", "3.10", "3.11", "3.12"] os: [ubuntu-latest, macos-latest, windows-latest] steps: - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: - name: wheelhouse + name: wheelhouse-${{ matrix.python }} path: wheelhouse - run: python -m pip install --find-links wheelhouse aedat - run: python -c 'import aedat' @@ -56,7 +57,7 @@ jobs: steps: - uses: actions/checkout@v4 - run: pipx run build --sdist - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: dist path: dist/*.tar.gz @@ -66,11 +67,12 @@ jobs: needs: [build_wheels, import_library, build_sdist] if: github.event_name == 'release' && github.event.action == 'published' steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: - name: wheelhouse path: wheelhouse - - uses: actions/download-artifact@v3 + pattern: wheelhouse-* + merge-multiple: true + - uses: actions/download-artifact@v4 with: name: dist path: dist diff --git a/Cargo.lock b/Cargo.lock index 285f7c2..0679613 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "aedat" -version = "2.0.3" +version = "2.1.0" dependencies = [ "flatbuffers", "lz4", @@ -15,22 +15,11 @@ dependencies = [ "zstd", ] -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - [[package]] name = "autocfg" -version = "1.0.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bitflags" @@ -38,13 +27,21 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + [[package]] name = "cc" -version = "1.0.71" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" dependencies = [ "jobserver", + "libc", + "once_cell", ] [[package]] @@ -55,61 +52,48 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "flatbuffers" -version = "22.10.26" +version = "24.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ba319fc85cd1d8994d42c95b13cdf051786b35f9e401b1c03bff1c67efd899" +checksum = "8add37afff2d4ffa83bc748a70b4b1370984f6980768554182424ef71447c35f" dependencies = [ - "bitflags", + "bitflags 1.3.2", "rustc_version", ] [[package]] -name = "getrandom" -version = "0.2.8" +name = "heck" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "indoc" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adab1eaa3408fb7f0c777a73e7465fd5656136fc93b670eb6df3c88c2c1344e3" - -[[package]] -name = "instant" -version = "0.1.12" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "jobserver" -version = "0.1.24" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" dependencies = [ "libc", ] [[package]] name = "libc" -version = "0.2.137" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "lock_api" -version = "0.4.5" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ + "autocfg", "scopeguard", ] @@ -135,18 +119,19 @@ dependencies = [ [[package]] name = "matrixmultiply" -version = "0.3.2" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" +checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2" dependencies = [ + "autocfg", "rawpointer", ] [[package]] name = "memoffset" -version = "0.6.5" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] @@ -166,98 +151,108 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.0" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ "num-traits", ] [[package]] name = "num-integer" -version = "0.1.44" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "numpy" -version = "0.17.2" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a462c1af5ba1fddec1488c4646993a23ae7931f9e170ccba23e9c7c834277797" +checksum = "ec170733ca37175f5d75a5bea5911d6ff45d2cd52849ce98b685394e4f2f37f4" dependencies = [ - "ahash", "libc", "ndarray", "num-complex", "num-integer", "num-traits", "pyo3", + "rustc-hash", ] [[package]] name = "once_cell" -version = "1.8.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "parking_lot" -version = "0.11.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ - "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", - "instant", "libc", "redox_syscall", "smallvec", - "winapi", + "windows-targets", ] +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "portable-atomic" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" + [[package]] name = "proc-macro2" -version = "1.0.30" +version = "1.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc3358ebc67bc8b7fa0c007f945b0b18226f78437d61bec735a9eb96b61ee70" +checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "pyo3" -version = "0.17.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "268be0c73583c183f2b14052337465768c07726936a260f480f0857cb95ba543" +checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" dependencies = [ "cfg-if", "indoc", "libc", "memoffset", "parking_lot", + "portable-atomic", "pyo3-build-config", "pyo3-ffi", "pyo3-macros", @@ -266,9 +261,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.17.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28fcd1e73f06ec85bf3280c48c67e731d8290ad3d730f8be9dc07946923005c8" +checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" dependencies = [ "once_cell", "target-lexicon", @@ -276,9 +271,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.17.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f6cb136e222e49115b3c51c32792886defbfb0adead26a688142b346a0b9ffc" +checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" dependencies = [ "libc", "pyo3-build-config", @@ -286,9 +281,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.17.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94144a1266e236b1c932682136dc35a9dee8d3589728f68130c7c3861ef96b28" +checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -298,20 +293,22 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.17.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8df9be978a2d2f0cdebabb03206ed73b11314701a5bfe71b0d753b81997777f" +checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" dependencies = [ + "heck", "proc-macro2", + "pyo3-build-config", "quote", "syn", ] [[package]] name = "quote" -version = "1.0.10" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -324,21 +321,24 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "redox_syscall" -version = "0.2.10" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags", + "bitflags 2.5.0", ] [[package]] name = "roxmltree" -version = "0.15.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b9de9831a129b122e7e61f242db509fa9d0838008bf0b29bb0624669edfe48a" -dependencies = [ - "xmlparser", -] +checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustc_version" @@ -351,116 +351,139 @@ dependencies = [ [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.14" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "smallvec" -version = "1.7.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "syn" -version = "1.0.80" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] name = "target-lexicon" -version = "0.12.5" +version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" +checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] -name = "unicode-xid" -version = "0.2.2" +name = "unicode-ident" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unindent" -version = "0.1.7" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" +checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" [[package]] -name = "version_check" -version = "0.9.4" +name = "windows-targets" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] [[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +name = "windows_aarch64_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] -name = "winapi" -version = "0.3.9" +name = "windows_aarch64_msvc" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "windows_i686_gnu" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] -name = "xmlparser" -version = "0.13.5" +name = "windows_x86_64_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d25c75bf9ea12c4040a97f829154768bbbce366287e2dc044af160cd79a13fd" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "zstd" -version = "0.11.2+zstd.1.5.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +checksum = "1cd99b45c6bc03a018c8b8a86025678c87e55526064e38f9df301989dce7ec0a" dependencies = [ - "libc", "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.1+zstd.1.5.2" +version = "2.0.10+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b" +checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" dependencies = [ "cc", - "libc", + "pkg-config", ] diff --git a/Cargo.toml b/Cargo.toml index 6ce27dc..4039716 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,8 @@ [package] name = "aedat" -version = "2.0.3" +version = "2.1.0" edition = "2021" +resolver = "2" [profile.release] lto = true @@ -11,10 +12,10 @@ name = "aedat" crate-type = ["cdylib"] [dependencies] -flatbuffers = "22.10.26" +flatbuffers = "24.3.25" lz4 = "1.24.0" ndarray = "0.15.6" -numpy = "0.17.2" -pyo3 = {version = "0.17.3", features = ["extension-module"]} -roxmltree = "0.15.1" -zstd = "0.11.2" +numpy = "0.21.0" +pyo3 = {version = "0.21.2", features = ["extension-module"]} +roxmltree = "0.20.0" +zstd = "0.13.1" diff --git a/pyproject.toml b/pyproject.toml index c2b73e2..8caeb65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ authors = [ {name = "International Centre for Neuromorphic Systems"}, {name = "Alexandre Marcireau"}, ] -version = "2.0.3" +version = "2.1.0" requires-python = ">=3.8" dependencies = ["numpy>=1.24"] @@ -17,5 +17,5 @@ repository = "https://github.com/neuromorphicsystems/aedat/" documentation = "https://github.com/neuromorphicsystems/aedat/" [build-system] -requires = ["maturin>=0.12", "numpy"] +requires = ["maturin==1.5.1", "numpy>=1.24"] build-backend = "maturin" diff --git a/src/events_generated.rs b/src/events_generated.rs index e4a8e46..a416596 100644 --- a/src/events_generated.rs +++ b/src/events_generated.rs @@ -1,9 +1,10 @@ // automatically generated by the FlatBuffers compiler, do not modify + // @generated -use core::cmp::Ordering; use core::mem; +use core::cmp::Ordering; extern crate flatbuffers; use self::flatbuffers::{EndianScalar, Follow}; @@ -12,36 +13,36 @@ use self::flatbuffers::{EndianScalar, Follow}; #[repr(transparent)] #[derive(Clone, Copy, PartialEq)] pub struct Event(pub [u8; 16]); -impl Default for Event { - fn default() -> Self { - Self([0; 16]) - } +impl Default for Event { + fn default() -> Self { + Self([0; 16]) + } } impl core::fmt::Debug for Event { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - f.debug_struct("Event") - .field("t", &self.t()) - .field("x", &self.x()) - .field("y", &self.y()) - .field("on", &self.on()) - .finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + f.debug_struct("Event") + .field("t", &self.t()) + .field("x", &self.x()) + .field("y", &self.y()) + .field("on", &self.on()) + .finish() + } } impl flatbuffers::SimpleToVerifyInSlice for Event {} impl<'a> flatbuffers::Follow<'a> for Event { - type Inner = &'a Event; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - <&'a Event>::follow(buf, loc) - } + type Inner = &'a Event; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + <&'a Event>::follow(buf, loc) + } } impl<'a> flatbuffers::Follow<'a> for &'a Event { - type Inner = &'a Event; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) - } + type Inner = &'a Event; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + flatbuffers::follow_cast_ref::(buf, loc) + } } impl<'b> flatbuffers::Push for Event { type Output = Event; @@ -53,256 +54,245 @@ impl<'b> flatbuffers::Push for Event { } impl<'a> flatbuffers::Verifiable for Event { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.in_buffer::(pos) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.in_buffer::(pos) + } } impl<'a> Event { - #[allow(clippy::too_many_arguments)] - pub fn new(t: i64, x: i16, y: i16, on: bool) -> Self { - let mut s = Self([0; 16]); - s.set_t(t); - s.set_x(x); - s.set_y(y); - s.set_on(on); - s - } + #[allow(clippy::too_many_arguments)] + pub fn new( + t: i64, + x: i16, + y: i16, + on: bool, + ) -> Self { + let mut s = Self([0; 16]); + s.set_t(t); + s.set_x(x); + s.set_y(y); + s.set_on(on); + s + } - pub fn t(&self) -> i64 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - EndianScalar::from_little_endian(unsafe { - core::ptr::copy_nonoverlapping( - self.0[0..].as_ptr(), - mem.as_mut_ptr() as *mut u8, - core::mem::size_of::<::Scalar>(), - ); - mem.assume_init() - }) - } + pub fn t(&self) -> i64 { + let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid value in this slot + EndianScalar::from_little_endian(unsafe { + core::ptr::copy_nonoverlapping( + self.0[0..].as_ptr(), + mem.as_mut_ptr() as *mut u8, + core::mem::size_of::<::Scalar>(), + ); + mem.assume_init() + }) + } - pub fn set_t(&mut self, x: i64) { - let x_le = x.to_little_endian(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - unsafe { - core::ptr::copy_nonoverlapping( - &x_le as *const _ as *const u8, - self.0[0..].as_mut_ptr(), - core::mem::size_of::<::Scalar>(), - ); - } + pub fn set_t(&mut self, x: i64) { + let x_le = x.to_little_endian(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid value in this slot + unsafe { + core::ptr::copy_nonoverlapping( + &x_le as *const _ as *const u8, + self.0[0..].as_mut_ptr(), + core::mem::size_of::<::Scalar>(), + ); } + } - pub fn x(&self) -> i16 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - EndianScalar::from_little_endian(unsafe { - core::ptr::copy_nonoverlapping( - self.0[8..].as_ptr(), - mem.as_mut_ptr() as *mut u8, - core::mem::size_of::<::Scalar>(), - ); - mem.assume_init() - }) - } + pub fn x(&self) -> i16 { + let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid value in this slot + EndianScalar::from_little_endian(unsafe { + core::ptr::copy_nonoverlapping( + self.0[8..].as_ptr(), + mem.as_mut_ptr() as *mut u8, + core::mem::size_of::<::Scalar>(), + ); + mem.assume_init() + }) + } - pub fn set_x(&mut self, x: i16) { - let x_le = x.to_little_endian(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - unsafe { - core::ptr::copy_nonoverlapping( - &x_le as *const _ as *const u8, - self.0[8..].as_mut_ptr(), - core::mem::size_of::<::Scalar>(), - ); - } + pub fn set_x(&mut self, x: i16) { + let x_le = x.to_little_endian(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid value in this slot + unsafe { + core::ptr::copy_nonoverlapping( + &x_le as *const _ as *const u8, + self.0[8..].as_mut_ptr(), + core::mem::size_of::<::Scalar>(), + ); } + } - pub fn y(&self) -> i16 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - EndianScalar::from_little_endian(unsafe { - core::ptr::copy_nonoverlapping( - self.0[10..].as_ptr(), - mem.as_mut_ptr() as *mut u8, - core::mem::size_of::<::Scalar>(), - ); - mem.assume_init() - }) - } + pub fn y(&self) -> i16 { + let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid value in this slot + EndianScalar::from_little_endian(unsafe { + core::ptr::copy_nonoverlapping( + self.0[10..].as_ptr(), + mem.as_mut_ptr() as *mut u8, + core::mem::size_of::<::Scalar>(), + ); + mem.assume_init() + }) + } - pub fn set_y(&mut self, x: i16) { - let x_le = x.to_little_endian(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - unsafe { - core::ptr::copy_nonoverlapping( - &x_le as *const _ as *const u8, - self.0[10..].as_mut_ptr(), - core::mem::size_of::<::Scalar>(), - ); - } + pub fn set_y(&mut self, x: i16) { + let x_le = x.to_little_endian(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid value in this slot + unsafe { + core::ptr::copy_nonoverlapping( + &x_le as *const _ as *const u8, + self.0[10..].as_mut_ptr(), + core::mem::size_of::<::Scalar>(), + ); } + } - pub fn on(&self) -> bool { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - EndianScalar::from_little_endian(unsafe { - core::ptr::copy_nonoverlapping( - self.0[12..].as_ptr(), - mem.as_mut_ptr() as *mut u8, - core::mem::size_of::<::Scalar>(), - ); - mem.assume_init() - }) - } + pub fn on(&self) -> bool { + let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid value in this slot + EndianScalar::from_little_endian(unsafe { + core::ptr::copy_nonoverlapping( + self.0[12..].as_ptr(), + mem.as_mut_ptr() as *mut u8, + core::mem::size_of::<::Scalar>(), + ); + mem.assume_init() + }) + } - pub fn set_on(&mut self, x: bool) { - let x_le = x.to_little_endian(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - unsafe { - core::ptr::copy_nonoverlapping( - &x_le as *const _ as *const u8, - self.0[12..].as_mut_ptr(), - core::mem::size_of::<::Scalar>(), - ); - } + pub fn set_on(&mut self, x: bool) { + let x_le = x.to_little_endian(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid value in this slot + unsafe { + core::ptr::copy_nonoverlapping( + &x_le as *const _ as *const u8, + self.0[12..].as_mut_ptr(), + core::mem::size_of::<::Scalar>(), + ); } + } + } pub enum EventPacketOffset {} #[derive(Copy, Clone, PartialEq)] pub struct EventPacket<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } impl<'a> flatbuffers::Follow<'a> for EventPacket<'a> { - type Inner = EventPacket<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } + type Inner = EventPacket<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } } impl<'a> EventPacket<'a> { - pub const VT_ELEMENTS: flatbuffers::VOffsetT = 4; + pub const VT_ELEMENTS: flatbuffers::VOffsetT = 4; - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - EventPacket { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args EventPacketArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = EventPacketBuilder::new(_fbb); - if let Some(x) = args.elements { - builder.add_elements(x); - } - builder.finish() - } + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + EventPacket { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, + args: &'args EventPacketArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = EventPacketBuilder::new(_fbb); + if let Some(x) = args.elements { builder.add_elements(x); } + builder.finish() + } - #[inline] - pub fn elements(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - EventPacket::VT_ELEMENTS, - None, - ) - } - } + + #[inline] + pub fn elements(&self) -> Option> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>(EventPacket::VT_ELEMENTS, None)} + } } impl flatbuffers::Verifiable for EventPacket<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>>( - "elements", - Self::VT_ELEMENTS, - false, - )? - .finish(); - Ok(()) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>>("elements", Self::VT_ELEMENTS, false)? + .finish(); + Ok(()) + } } pub struct EventPacketArgs<'a> { pub elements: Option>>, } impl<'a> Default for EventPacketArgs<'a> { - #[inline] - fn default() -> Self { - EventPacketArgs { elements: None } + #[inline] + fn default() -> Self { + EventPacketArgs { + elements: None, } + } } -pub struct EventPacketBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, +pub struct EventPacketBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b> EventPacketBuilder<'a, 'b> { - #[inline] - pub fn add_elements( - &mut self, - elements: flatbuffers::WIPOffset>, - ) { - self.fbb_ - .push_slot_always::>(EventPacket::VT_ELEMENTS, elements); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> EventPacketBuilder<'a, 'b> { - let start = _fbb.start_table(); - EventPacketBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> EventPacketBuilder<'a, 'b, A> { + #[inline] + pub fn add_elements(&mut self, elements: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(EventPacket::VT_ELEMENTS, elements); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> EventPacketBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + EventPacketBuilder { + fbb_: _fbb, + start_: start, } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } } impl core::fmt::Debug for EventPacket<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("EventPacket"); - ds.field("elements", &self.elements()); - ds.finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("EventPacket"); + ds.field("elements", &self.elements()); + ds.finish() + } } #[inline] /// Verifies that a buffer of bytes contains a `EventPacket` @@ -312,7 +302,7 @@ impl core::fmt::Debug for EventPacket<'_> { /// previous, unchecked, behavior use /// `root_as_event_packet_unchecked`. pub fn root_as_event_packet(buf: &[u8]) -> Result { - flatbuffers::root::(buf) + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -321,10 +311,8 @@ pub fn root_as_event_packet(buf: &[u8]) -> Result Result { - flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_event_packet(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -334,10 +322,10 @@ pub fn size_prefixed_root_as_event_packet( /// previous, unchecked, behavior use /// `root_as_event_packet_unchecked`. pub fn root_as_event_packet_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -347,49 +335,45 @@ pub fn root_as_event_packet_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_event_packet_unchecked`. pub fn size_prefixed_root_as_event_packet_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a EventPacket and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `EventPacket`. pub unsafe fn root_as_event_packet_unchecked(buf: &[u8]) -> EventPacket { - flatbuffers::root_unchecked::(buf) + flatbuffers::root_unchecked::(buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed EventPacket and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `EventPacket`. pub unsafe fn size_prefixed_root_as_event_packet_unchecked(buf: &[u8]) -> EventPacket { - flatbuffers::size_prefixed_root_unchecked::(buf) + flatbuffers::size_prefixed_root_unchecked::(buf) } pub const EVENT_PACKET_IDENTIFIER: &str = "EVTS"; #[inline] pub fn event_packet_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, EVENT_PACKET_IDENTIFIER, false) + flatbuffers::buffer_has_identifier(buf, EVENT_PACKET_IDENTIFIER, false) } #[inline] pub fn event_packet_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, EVENT_PACKET_IDENTIFIER, true) + flatbuffers::buffer_has_identifier(buf, EVENT_PACKET_IDENTIFIER, true) } #[inline] -pub fn finish_event_packet_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish(root, Some(EVENT_PACKET_IDENTIFIER)); +pub fn finish_event_packet_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( + fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + root: flatbuffers::WIPOffset>) { + fbb.finish(root, Some(EVENT_PACKET_IDENTIFIER)); } #[inline] -pub fn finish_size_prefixed_event_packet_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, Some(EVENT_PACKET_IDENTIFIER)); +pub fn finish_size_prefixed_event_packet_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { + fbb.finish_size_prefixed(root, Some(EVENT_PACKET_IDENTIFIER)); } diff --git a/src/frame_generated.rs b/src/frame_generated.rs index f9f46d9..f026f8d 100644 --- a/src/frame_generated.rs +++ b/src/frame_generated.rs @@ -1,69 +1,68 @@ // automatically generated by the FlatBuffers compiler, do not modify + // @generated -use core::cmp::Ordering; use core::mem; +use core::cmp::Ordering; extern crate flatbuffers; use self::flatbuffers::{EndianScalar, Follow}; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MIN_FRAME_FORMAT: i8 = 0; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MAX_FRAME_FORMAT: i8 = 24; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] #[allow(non_camel_case_types)] -pub const ENUM_VALUES_FRAME_FORMAT: [FrameFormat; 3] = - [FrameFormat::Gray, FrameFormat::Bgr, FrameFormat::Bgra]; +pub const ENUM_VALUES_FRAME_FORMAT: [FrameFormat; 3] = [ + FrameFormat::Gray, + FrameFormat::Bgr, + FrameFormat::Bgra, +]; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[repr(transparent)] pub struct FrameFormat(pub i8); #[allow(non_upper_case_globals)] impl FrameFormat { - pub const Gray: Self = Self(0); - pub const Bgr: Self = Self(16); - pub const Bgra: Self = Self(24); + pub const Gray: Self = Self(0); + pub const Bgr: Self = Self(16); + pub const Bgra: Self = Self(24); - pub const ENUM_MIN: i8 = 0; - pub const ENUM_MAX: i8 = 24; - pub const ENUM_VALUES: &'static [Self] = &[Self::Gray, Self::Bgr, Self::Bgra]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::Gray => Some("Gray"), - Self::Bgr => Some("Bgr"), - Self::Bgra => Some("Bgra"), - _ => None, - } - } + pub const ENUM_MIN: i8 = 0; + pub const ENUM_MAX: i8 = 24; + pub const ENUM_VALUES: &'static [Self] = &[ + Self::Gray, + Self::Bgr, + Self::Bgra, + ]; + /// Returns the variant's name or "" if unknown. + pub fn variant_name(self) -> Option<&'static str> { + match self { + Self::Gray => Some("Gray"), + Self::Bgr => Some("Bgr"), + Self::Bgra => Some("Bgra"), + _ => None, + } + } } impl core::fmt::Debug for FrameFormat { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - if let Some(name) = self.variant_name() { - f.write_str(name) - } else { - f.write_fmt(format_args!("", self.0)) - } + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + if let Some(name) = self.variant_name() { + f.write_str(name) + } else { + f.write_fmt(format_args!("", self.0)) } + } } impl<'a> flatbuffers::Follow<'a> for FrameFormat { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); - Self(b) - } + type Inner = Self; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self(b) + } } impl flatbuffers::Push for FrameFormat { @@ -75,28 +74,27 @@ impl flatbuffers::Push for FrameFormat { } impl flatbuffers::EndianScalar for FrameFormat { - type Scalar = i8; - #[inline] - fn to_little_endian(self) -> i8 { - self.0.to_le() - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(v: i8) -> Self { - let b = i8::from_le(v); - Self(b) - } + type Scalar = i8; + #[inline] + fn to_little_endian(self) -> i8 { + self.0.to_le() + } + #[inline] + #[allow(clippy::wrong_self_convention)] + fn from_little_endian(v: i8) -> Self { + let b = i8::from_le(v); + Self(b) + } } impl<'a> flatbuffers::Verifiable for FrameFormat { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - i8::run_verifier(v, pos) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + i8::run_verifier(v, pos) + } } impl flatbuffers::SimpleToVerifyInSlice for FrameFormat {} @@ -104,181 +102,155 @@ pub enum FrameOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Frame<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } impl<'a> flatbuffers::Follow<'a> for Frame<'a> { - type Inner = Frame<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } + type Inner = Frame<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } } impl<'a> Frame<'a> { - pub const VT_T: flatbuffers::VOffsetT = 4; - pub const VT_BEGIN_T: flatbuffers::VOffsetT = 6; - pub const VT_END_T: flatbuffers::VOffsetT = 8; - pub const VT_EXPOSURE_BEGIN_T: flatbuffers::VOffsetT = 10; - pub const VT_EXPOSURE_END_T: flatbuffers::VOffsetT = 12; - pub const VT_FORMAT: flatbuffers::VOffsetT = 14; - pub const VT_WIDTH: flatbuffers::VOffsetT = 16; - pub const VT_HEIGHT: flatbuffers::VOffsetT = 18; - pub const VT_OFFSET_X: flatbuffers::VOffsetT = 20; - pub const VT_OFFSET_Y: flatbuffers::VOffsetT = 22; - pub const VT_PIXELS: flatbuffers::VOffsetT = 24; + pub const VT_T: flatbuffers::VOffsetT = 4; + pub const VT_BEGIN_T: flatbuffers::VOffsetT = 6; + pub const VT_END_T: flatbuffers::VOffsetT = 8; + pub const VT_EXPOSURE_BEGIN_T: flatbuffers::VOffsetT = 10; + pub const VT_EXPOSURE_END_T: flatbuffers::VOffsetT = 12; + pub const VT_FORMAT: flatbuffers::VOffsetT = 14; + pub const VT_WIDTH: flatbuffers::VOffsetT = 16; + pub const VT_HEIGHT: flatbuffers::VOffsetT = 18; + pub const VT_OFFSET_X: flatbuffers::VOffsetT = 20; + pub const VT_OFFSET_Y: flatbuffers::VOffsetT = 22; + pub const VT_PIXELS: flatbuffers::VOffsetT = 24; - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Frame { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args FrameArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = FrameBuilder::new(_fbb); - builder.add_exposure_end_t(args.exposure_end_t); - builder.add_exposure_begin_t(args.exposure_begin_t); - builder.add_end_t(args.end_t); - builder.add_begin_t(args.begin_t); - builder.add_t(args.t); - if let Some(x) = args.pixels { - builder.add_pixels(x); - } - builder.add_offset_y(args.offset_y); - builder.add_offset_x(args.offset_x); - builder.add_height(args.height); - builder.add_width(args.width); - builder.add_format(args.format); - builder.finish() - } + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Frame { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, + args: &'args FrameArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = FrameBuilder::new(_fbb); + builder.add_exposure_end_t(args.exposure_end_t); + builder.add_exposure_begin_t(args.exposure_begin_t); + builder.add_end_t(args.end_t); + builder.add_begin_t(args.begin_t); + builder.add_t(args.t); + if let Some(x) = args.pixels { builder.add_pixels(x); } + builder.add_offset_y(args.offset_y); + builder.add_offset_x(args.offset_x); + builder.add_height(args.height); + builder.add_width(args.width); + builder.add_format(args.format); + builder.finish() + } - #[inline] - pub fn t(&self) -> i64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Frame::VT_T, Some(0)).unwrap() } - } - #[inline] - pub fn begin_t(&self) -> i64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Frame::VT_BEGIN_T, Some(0)).unwrap() } - } - #[inline] - pub fn end_t(&self) -> i64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Frame::VT_END_T, Some(0)).unwrap() } - } - #[inline] - pub fn exposure_begin_t(&self) -> i64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Frame::VT_EXPOSURE_BEGIN_T, Some(0)) - .unwrap() - } - } - #[inline] - pub fn exposure_end_t(&self) -> i64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Frame::VT_EXPOSURE_END_T, Some(0)) - .unwrap() - } - } - #[inline] - pub fn format(&self) -> FrameFormat { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Frame::VT_FORMAT, Some(FrameFormat::Gray)) - .unwrap() - } - } - #[inline] - pub fn width(&self) -> i16 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Frame::VT_WIDTH, Some(0)).unwrap() } - } - #[inline] - pub fn height(&self) -> i16 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Frame::VT_HEIGHT, Some(0)).unwrap() } - } - #[inline] - pub fn offset_x(&self) -> i16 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Frame::VT_OFFSET_X, Some(0)).unwrap() } - } - #[inline] - pub fn offset_y(&self) -> i16 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Frame::VT_OFFSET_Y, Some(0)).unwrap() } - } - #[inline] - pub fn pixels(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - Frame::VT_PIXELS, - None, - ) - } - } + + #[inline] + pub fn t(&self) -> i64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Frame::VT_T, Some(0)).unwrap()} + } + #[inline] + pub fn begin_t(&self) -> i64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Frame::VT_BEGIN_T, Some(0)).unwrap()} + } + #[inline] + pub fn end_t(&self) -> i64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Frame::VT_END_T, Some(0)).unwrap()} + } + #[inline] + pub fn exposure_begin_t(&self) -> i64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Frame::VT_EXPOSURE_BEGIN_T, Some(0)).unwrap()} + } + #[inline] + pub fn exposure_end_t(&self) -> i64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Frame::VT_EXPOSURE_END_T, Some(0)).unwrap()} + } + #[inline] + pub fn format(&self) -> FrameFormat { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Frame::VT_FORMAT, Some(FrameFormat::Gray)).unwrap()} + } + #[inline] + pub fn width(&self) -> i16 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Frame::VT_WIDTH, Some(0)).unwrap()} + } + #[inline] + pub fn height(&self) -> i16 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Frame::VT_HEIGHT, Some(0)).unwrap()} + } + #[inline] + pub fn offset_x(&self) -> i16 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Frame::VT_OFFSET_X, Some(0)).unwrap()} + } + #[inline] + pub fn offset_y(&self) -> i16 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Frame::VT_OFFSET_Y, Some(0)).unwrap()} + } + #[inline] + pub fn pixels(&self) -> Option> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>(Frame::VT_PIXELS, None)} + } } impl flatbuffers::Verifiable for Frame<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("t", Self::VT_T, false)? - .visit_field::("begin_t", Self::VT_BEGIN_T, false)? - .visit_field::("end_t", Self::VT_END_T, false)? - .visit_field::("exposure_begin_t", Self::VT_EXPOSURE_BEGIN_T, false)? - .visit_field::("exposure_end_t", Self::VT_EXPOSURE_END_T, false)? - .visit_field::("format", Self::VT_FORMAT, false)? - .visit_field::("width", Self::VT_WIDTH, false)? - .visit_field::("height", Self::VT_HEIGHT, false)? - .visit_field::("offset_x", Self::VT_OFFSET_X, false)? - .visit_field::("offset_y", Self::VT_OFFSET_Y, false)? - .visit_field::>>( - "pixels", - Self::VT_PIXELS, - false, - )? - .finish(); - Ok(()) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("t", Self::VT_T, false)? + .visit_field::("begin_t", Self::VT_BEGIN_T, false)? + .visit_field::("end_t", Self::VT_END_T, false)? + .visit_field::("exposure_begin_t", Self::VT_EXPOSURE_BEGIN_T, false)? + .visit_field::("exposure_end_t", Self::VT_EXPOSURE_END_T, false)? + .visit_field::("format", Self::VT_FORMAT, false)? + .visit_field::("width", Self::VT_WIDTH, false)? + .visit_field::("height", Self::VT_HEIGHT, false)? + .visit_field::("offset_x", Self::VT_OFFSET_X, false)? + .visit_field::("offset_y", Self::VT_OFFSET_Y, false)? + .visit_field::>>("pixels", Self::VT_PIXELS, false)? + .finish(); + Ok(()) + } } pub struct FrameArgs<'a> { pub t: i64, @@ -294,108 +266,104 @@ pub struct FrameArgs<'a> { pub pixels: Option>>, } impl<'a> Default for FrameArgs<'a> { - #[inline] - fn default() -> Self { - FrameArgs { - t: 0, - begin_t: 0, - end_t: 0, - exposure_begin_t: 0, - exposure_end_t: 0, - format: FrameFormat::Gray, - width: 0, - height: 0, - offset_x: 0, - offset_y: 0, - pixels: None, - } - } + #[inline] + fn default() -> Self { + FrameArgs { + t: 0, + begin_t: 0, + end_t: 0, + exposure_begin_t: 0, + exposure_end_t: 0, + format: FrameFormat::Gray, + width: 0, + height: 0, + offset_x: 0, + offset_y: 0, + pixels: None, + } + } } -pub struct FrameBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, +pub struct FrameBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b> FrameBuilder<'a, 'b> { - #[inline] - pub fn add_t(&mut self, t: i64) { - self.fbb_.push_slot::(Frame::VT_T, t, 0); - } - #[inline] - pub fn add_begin_t(&mut self, begin_t: i64) { - self.fbb_.push_slot::(Frame::VT_BEGIN_T, begin_t, 0); - } - #[inline] - pub fn add_end_t(&mut self, end_t: i64) { - self.fbb_.push_slot::(Frame::VT_END_T, end_t, 0); - } - #[inline] - pub fn add_exposure_begin_t(&mut self, exposure_begin_t: i64) { - self.fbb_ - .push_slot::(Frame::VT_EXPOSURE_BEGIN_T, exposure_begin_t, 0); - } - #[inline] - pub fn add_exposure_end_t(&mut self, exposure_end_t: i64) { - self.fbb_ - .push_slot::(Frame::VT_EXPOSURE_END_T, exposure_end_t, 0); - } - #[inline] - pub fn add_format(&mut self, format: FrameFormat) { - self.fbb_ - .push_slot::(Frame::VT_FORMAT, format, FrameFormat::Gray); - } - #[inline] - pub fn add_width(&mut self, width: i16) { - self.fbb_.push_slot::(Frame::VT_WIDTH, width, 0); - } - #[inline] - pub fn add_height(&mut self, height: i16) { - self.fbb_.push_slot::(Frame::VT_HEIGHT, height, 0); - } - #[inline] - pub fn add_offset_x(&mut self, offset_x: i16) { - self.fbb_.push_slot::(Frame::VT_OFFSET_X, offset_x, 0); - } - #[inline] - pub fn add_offset_y(&mut self, offset_y: i16) { - self.fbb_.push_slot::(Frame::VT_OFFSET_Y, offset_y, 0); - } - #[inline] - pub fn add_pixels(&mut self, pixels: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>(Frame::VT_PIXELS, pixels); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> FrameBuilder<'a, 'b> { - let start = _fbb.start_table(); - FrameBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) - } +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FrameBuilder<'a, 'b, A> { + #[inline] + pub fn add_t(&mut self, t: i64) { + self.fbb_.push_slot::(Frame::VT_T, t, 0); + } + #[inline] + pub fn add_begin_t(&mut self, begin_t: i64) { + self.fbb_.push_slot::(Frame::VT_BEGIN_T, begin_t, 0); + } + #[inline] + pub fn add_end_t(&mut self, end_t: i64) { + self.fbb_.push_slot::(Frame::VT_END_T, end_t, 0); + } + #[inline] + pub fn add_exposure_begin_t(&mut self, exposure_begin_t: i64) { + self.fbb_.push_slot::(Frame::VT_EXPOSURE_BEGIN_T, exposure_begin_t, 0); + } + #[inline] + pub fn add_exposure_end_t(&mut self, exposure_end_t: i64) { + self.fbb_.push_slot::(Frame::VT_EXPOSURE_END_T, exposure_end_t, 0); + } + #[inline] + pub fn add_format(&mut self, format: FrameFormat) { + self.fbb_.push_slot::(Frame::VT_FORMAT, format, FrameFormat::Gray); + } + #[inline] + pub fn add_width(&mut self, width: i16) { + self.fbb_.push_slot::(Frame::VT_WIDTH, width, 0); + } + #[inline] + pub fn add_height(&mut self, height: i16) { + self.fbb_.push_slot::(Frame::VT_HEIGHT, height, 0); + } + #[inline] + pub fn add_offset_x(&mut self, offset_x: i16) { + self.fbb_.push_slot::(Frame::VT_OFFSET_X, offset_x, 0); + } + #[inline] + pub fn add_offset_y(&mut self, offset_y: i16) { + self.fbb_.push_slot::(Frame::VT_OFFSET_Y, offset_y, 0); + } + #[inline] + pub fn add_pixels(&mut self, pixels: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Frame::VT_PIXELS, pixels); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> FrameBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + FrameBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } } impl core::fmt::Debug for Frame<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Frame"); - ds.field("t", &self.t()); - ds.field("begin_t", &self.begin_t()); - ds.field("end_t", &self.end_t()); - ds.field("exposure_begin_t", &self.exposure_begin_t()); - ds.field("exposure_end_t", &self.exposure_end_t()); - ds.field("format", &self.format()); - ds.field("width", &self.width()); - ds.field("height", &self.height()); - ds.field("offset_x", &self.offset_x()); - ds.field("offset_y", &self.offset_y()); - ds.field("pixels", &self.pixels()); - ds.finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Frame"); + ds.field("t", &self.t()); + ds.field("begin_t", &self.begin_t()); + ds.field("end_t", &self.end_t()); + ds.field("exposure_begin_t", &self.exposure_begin_t()); + ds.field("exposure_end_t", &self.exposure_end_t()); + ds.field("format", &self.format()); + ds.field("width", &self.width()); + ds.field("height", &self.height()); + ds.field("offset_x", &self.offset_x()); + ds.field("offset_y", &self.offset_y()); + ds.field("pixels", &self.pixels()); + ds.finish() + } } #[inline] /// Verifies that a buffer of bytes contains a `Frame` @@ -405,7 +373,7 @@ impl core::fmt::Debug for Frame<'_> { /// previous, unchecked, behavior use /// `root_as_frame_unchecked`. pub fn root_as_frame(buf: &[u8]) -> Result { - flatbuffers::root::(buf) + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -415,7 +383,7 @@ pub fn root_as_frame(buf: &[u8]) -> Result Result { - flatbuffers::size_prefixed_root::(buf) + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -425,10 +393,10 @@ pub fn size_prefixed_root_as_frame(buf: &[u8]) -> Result( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -438,49 +406,45 @@ pub fn root_as_frame_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_frame_unchecked`. pub fn size_prefixed_root_as_frame_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a Frame and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `Frame`. pub unsafe fn root_as_frame_unchecked(buf: &[u8]) -> Frame { - flatbuffers::root_unchecked::(buf) + flatbuffers::root_unchecked::(buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed Frame and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `Frame`. pub unsafe fn size_prefixed_root_as_frame_unchecked(buf: &[u8]) -> Frame { - flatbuffers::size_prefixed_root_unchecked::(buf) + flatbuffers::size_prefixed_root_unchecked::(buf) } pub const FRAME_IDENTIFIER: &str = "FRME"; #[inline] pub fn frame_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, FRAME_IDENTIFIER, false) + flatbuffers::buffer_has_identifier(buf, FRAME_IDENTIFIER, false) } #[inline] pub fn frame_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, FRAME_IDENTIFIER, true) + flatbuffers::buffer_has_identifier(buf, FRAME_IDENTIFIER, true) } #[inline] -pub fn finish_frame_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish(root, Some(FRAME_IDENTIFIER)); +pub fn finish_frame_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( + fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + root: flatbuffers::WIPOffset>) { + fbb.finish(root, Some(FRAME_IDENTIFIER)); } #[inline] -pub fn finish_size_prefixed_frame_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, Some(FRAME_IDENTIFIER)); +pub fn finish_size_prefixed_frame_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { + fbb.finish_size_prefixed(root, Some(FRAME_IDENTIFIER)); } diff --git a/src/imus_generated.rs b/src/imus_generated.rs index 86a0d1c..b08fd6b 100644 --- a/src/imus_generated.rs +++ b/src/imus_generated.rs @@ -1,9 +1,10 @@ // automatically generated by the FlatBuffers compiler, do not modify + // @generated -use core::cmp::Ordering; use core::mem; +use core::cmp::Ordering; extern crate flatbuffers; use self::flatbuffers::{EndianScalar, Follow}; @@ -12,197 +13,155 @@ pub enum ImuOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Imu<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } impl<'a> flatbuffers::Follow<'a> for Imu<'a> { - type Inner = Imu<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } + type Inner = Imu<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } } impl<'a> Imu<'a> { - 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; + 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 unsafe 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> { - 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() - } + #[inline] + pub unsafe 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, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, + args: &'args ImuArgs + ) -> flatbuffers::WIPOffset> { + 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() + } - #[inline] - pub fn t(&self) -> i64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Imu::VT_T, Some(0)).unwrap() } - } - #[inline] - pub fn temperature(&self) -> f32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Imu::VT_TEMPERATURE, Some(0.0)) - .unwrap() - } - } - #[inline] - pub fn accelerometer_x(&self) -> f32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Imu::VT_ACCELEROMETER_X, Some(0.0)) - .unwrap() - } - } - #[inline] - pub fn accelerometer_y(&self) -> f32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Imu::VT_ACCELEROMETER_Y, Some(0.0)) - .unwrap() - } - } - #[inline] - pub fn accelerometer_z(&self) -> f32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Imu::VT_ACCELEROMETER_Z, Some(0.0)) - .unwrap() - } - } - #[inline] - pub fn gyroscope_x(&self) -> f32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Imu::VT_GYROSCOPE_X, Some(0.0)) - .unwrap() - } - } - #[inline] - pub fn gyroscope_y(&self) -> f32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Imu::VT_GYROSCOPE_Y, Some(0.0)) - .unwrap() - } - } - #[inline] - pub fn gyroscope_z(&self) -> f32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Imu::VT_GYROSCOPE_Z, Some(0.0)) - .unwrap() - } - } - #[inline] - pub fn magnetometer_x(&self) -> f32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Imu::VT_MAGNETOMETER_X, Some(0.0)) - .unwrap() - } - } - #[inline] - pub fn magnetometer_y(&self) -> f32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Imu::VT_MAGNETOMETER_Y, Some(0.0)) - .unwrap() - } - } - #[inline] - pub fn magnetometer_z(&self) -> f32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Imu::VT_MAGNETOMETER_Z, Some(0.0)) - .unwrap() - } - } + + #[inline] + pub fn t(&self) -> i64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Imu::VT_T, Some(0)).unwrap()} + } + #[inline] + pub fn temperature(&self) -> f32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Imu::VT_TEMPERATURE, Some(0.0)).unwrap()} + } + #[inline] + pub fn accelerometer_x(&self) -> f32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Imu::VT_ACCELEROMETER_X, Some(0.0)).unwrap()} + } + #[inline] + pub fn accelerometer_y(&self) -> f32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Imu::VT_ACCELEROMETER_Y, Some(0.0)).unwrap()} + } + #[inline] + pub fn accelerometer_z(&self) -> f32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Imu::VT_ACCELEROMETER_Z, Some(0.0)).unwrap()} + } + #[inline] + pub fn gyroscope_x(&self) -> f32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Imu::VT_GYROSCOPE_X, Some(0.0)).unwrap()} + } + #[inline] + pub fn gyroscope_y(&self) -> f32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Imu::VT_GYROSCOPE_Y, Some(0.0)).unwrap()} + } + #[inline] + pub fn gyroscope_z(&self) -> f32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Imu::VT_GYROSCOPE_Z, Some(0.0)).unwrap()} + } + #[inline] + pub fn magnetometer_x(&self) -> f32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Imu::VT_MAGNETOMETER_X, Some(0.0)).unwrap()} + } + #[inline] + pub fn magnetometer_y(&self) -> f32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Imu::VT_MAGNETOMETER_Y, Some(0.0)).unwrap()} + } + #[inline] + pub fn magnetometer_z(&self) -> f32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(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::("t", Self::VT_T, false)? - .visit_field::("temperature", Self::VT_TEMPERATURE, false)? - .visit_field::("accelerometer_x", Self::VT_ACCELEROMETER_X, false)? - .visit_field::("accelerometer_y", Self::VT_ACCELEROMETER_Y, false)? - .visit_field::("accelerometer_z", Self::VT_ACCELEROMETER_Z, false)? - .visit_field::("gyroscope_x", Self::VT_GYROSCOPE_X, false)? - .visit_field::("gyroscope_y", Self::VT_GYROSCOPE_Y, false)? - .visit_field::("gyroscope_z", Self::VT_GYROSCOPE_Z, false)? - .visit_field::("magnetometer_x", Self::VT_MAGNETOMETER_X, false)? - .visit_field::("magnetometer_y", Self::VT_MAGNETOMETER_Y, false)? - .visit_field::("magnetometer_z", Self::VT_MAGNETOMETER_Z, false)? - .finish(); - Ok(()) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("t", Self::VT_T, false)? + .visit_field::("temperature", Self::VT_TEMPERATURE, false)? + .visit_field::("accelerometer_x", Self::VT_ACCELEROMETER_X, false)? + .visit_field::("accelerometer_y", Self::VT_ACCELEROMETER_Y, false)? + .visit_field::("accelerometer_z", Self::VT_ACCELEROMETER_Z, false)? + .visit_field::("gyroscope_x", Self::VT_GYROSCOPE_X, false)? + .visit_field::("gyroscope_y", Self::VT_GYROSCOPE_Y, false)? + .visit_field::("gyroscope_z", Self::VT_GYROSCOPE_Z, false)? + .visit_field::("magnetometer_x", Self::VT_MAGNETOMETER_X, false)? + .visit_field::("magnetometer_y", Self::VT_MAGNETOMETER_Y, false)? + .visit_field::("magnetometer_z", Self::VT_MAGNETOMETER_Z, false)? + .finish(); + Ok(()) + } } pub struct ImuArgs { pub t: i64, @@ -218,229 +177,201 @@ pub struct ImuArgs { 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, - } - } + #[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, +pub struct ImuBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b> ImuBuilder<'a, 'b> { - #[inline] - pub fn add_t(&mut self, t: i64) { - self.fbb_.push_slot::(Imu::VT_T, t, 0); - } - #[inline] - pub fn add_temperature(&mut self, temperature: f32) { - self.fbb_ - .push_slot::(Imu::VT_TEMPERATURE, temperature, 0.0); - } - #[inline] - pub fn add_accelerometer_x(&mut self, accelerometer_x: f32) { - self.fbb_ - .push_slot::(Imu::VT_ACCELEROMETER_X, accelerometer_x, 0.0); - } - #[inline] - pub fn add_accelerometer_y(&mut self, accelerometer_y: f32) { - self.fbb_ - .push_slot::(Imu::VT_ACCELEROMETER_Y, accelerometer_y, 0.0); - } - #[inline] - pub fn add_accelerometer_z(&mut self, accelerometer_z: f32) { - self.fbb_ - .push_slot::(Imu::VT_ACCELEROMETER_Z, accelerometer_z, 0.0); - } - #[inline] - pub fn add_gyroscope_x(&mut self, gyroscope_x: f32) { - self.fbb_ - .push_slot::(Imu::VT_GYROSCOPE_X, gyroscope_x, 0.0); - } - #[inline] - pub fn add_gyroscope_y(&mut self, gyroscope_y: f32) { - self.fbb_ - .push_slot::(Imu::VT_GYROSCOPE_Y, gyroscope_y, 0.0); - } - #[inline] - pub fn add_gyroscope_z(&mut self, gyroscope_z: f32) { - self.fbb_ - .push_slot::(Imu::VT_GYROSCOPE_Z, gyroscope_z, 0.0); - } - #[inline] - pub fn add_magnetometer_x(&mut self, magnetometer_x: f32) { - self.fbb_ - .push_slot::(Imu::VT_MAGNETOMETER_X, magnetometer_x, 0.0); - } - #[inline] - pub fn add_magnetometer_y(&mut self, magnetometer_y: f32) { - self.fbb_ - .push_slot::(Imu::VT_MAGNETOMETER_Y, magnetometer_y, 0.0); - } - #[inline] - pub fn add_magnetometer_z(&mut self, magnetometer_z: f32) { - self.fbb_ - .push_slot::(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> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) - } +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ImuBuilder<'a, 'b, A> { + #[inline] + pub fn add_t(&mut self, t: i64) { + self.fbb_.push_slot::(Imu::VT_T, t, 0); + } + #[inline] + pub fn add_temperature(&mut self, temperature: f32) { + self.fbb_.push_slot::(Imu::VT_TEMPERATURE, temperature, 0.0); + } + #[inline] + pub fn add_accelerometer_x(&mut self, accelerometer_x: f32) { + self.fbb_.push_slot::(Imu::VT_ACCELEROMETER_X, accelerometer_x, 0.0); + } + #[inline] + pub fn add_accelerometer_y(&mut self, accelerometer_y: f32) { + self.fbb_.push_slot::(Imu::VT_ACCELEROMETER_Y, accelerometer_y, 0.0); + } + #[inline] + pub fn add_accelerometer_z(&mut self, accelerometer_z: f32) { + self.fbb_.push_slot::(Imu::VT_ACCELEROMETER_Z, accelerometer_z, 0.0); + } + #[inline] + pub fn add_gyroscope_x(&mut self, gyroscope_x: f32) { + self.fbb_.push_slot::(Imu::VT_GYROSCOPE_X, gyroscope_x, 0.0); + } + #[inline] + pub fn add_gyroscope_y(&mut self, gyroscope_y: f32) { + self.fbb_.push_slot::(Imu::VT_GYROSCOPE_Y, gyroscope_y, 0.0); + } + #[inline] + pub fn add_gyroscope_z(&mut self, gyroscope_z: f32) { + self.fbb_.push_slot::(Imu::VT_GYROSCOPE_Z, gyroscope_z, 0.0); + } + #[inline] + pub fn add_magnetometer_x(&mut self, magnetometer_x: f32) { + self.fbb_.push_slot::(Imu::VT_MAGNETOMETER_X, magnetometer_x, 0.0); + } + #[inline] + pub fn add_magnetometer_y(&mut self, magnetometer_y: f32) { + self.fbb_.push_slot::(Imu::VT_MAGNETOMETER_Y, magnetometer_y, 0.0); + } + #[inline] + pub fn add_magnetometer_z(&mut self, magnetometer_z: f32) { + self.fbb_.push_slot::(Imu::VT_MAGNETOMETER_Z, magnetometer_z, 0.0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ImuBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + ImuBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } } impl core::fmt::Debug for Imu<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::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() - } + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::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>, + pub _tab: flatbuffers::Table<'a>, } impl<'a> flatbuffers::Follow<'a> for ImuPacket<'a> { - type Inner = ImuPacket<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } + type Inner = ImuPacket<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } } impl<'a> ImuPacket<'a> { - pub const VT_ELEMENTS: flatbuffers::VOffsetT = 4; + pub const VT_ELEMENTS: flatbuffers::VOffsetT = 4; - #[inline] - pub unsafe 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> { - let mut builder = ImuPacketBuilder::new(_fbb); - if let Some(x) = args.elements { - builder.add_elements(x); - } - builder.finish() - } + #[inline] + pub unsafe 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, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, + args: &'args ImuPacketArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = ImuPacketBuilder::new(_fbb); + if let Some(x) = args.elements { builder.add_elements(x); } + builder.finish() + } - #[inline] - pub fn elements( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(ImuPacket::VT_ELEMENTS, None) - } - } + + #[inline] + pub fn elements(&self) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(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::>, - >>("elements", Self::VT_ELEMENTS, false)? - .finish(); - Ok(()) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>>>("elements", Self::VT_ELEMENTS, false)? + .finish(); + Ok(()) + } } pub struct ImuPacketArgs<'a> { - pub elements: Option< - flatbuffers::WIPOffset>>>, - >, + pub elements: Option>>>>, } impl<'a> Default for ImuPacketArgs<'a> { - #[inline] - fn default() -> Self { - ImuPacketArgs { elements: None } + #[inline] + fn default() -> Self { + ImuPacketArgs { + elements: None, } + } } -pub struct ImuPacketBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, +pub struct ImuPacketBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b> ImuPacketBuilder<'a, 'b> { - #[inline] - pub fn add_elements( - &mut self, - elements: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(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> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) - } +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ImuPacketBuilder<'a, 'b, A> { + #[inline] + pub fn add_elements(&mut self, elements: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(ImuPacket::VT_ELEMENTS, elements); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ImuPacketBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + ImuPacketBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } } impl core::fmt::Debug for ImuPacket<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("ImuPacket"); - ds.field("elements", &self.elements()); - ds.finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("ImuPacket"); + ds.field("elements", &self.elements()); + ds.finish() + } } #[inline] /// Verifies that a buffer of bytes contains a `ImuPacket` @@ -450,7 +381,7 @@ impl core::fmt::Debug for ImuPacket<'_> { /// previous, unchecked, behavior use /// `root_as_imu_packet_unchecked`. pub fn root_as_imu_packet(buf: &[u8]) -> Result { - flatbuffers::root::(buf) + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -459,10 +390,8 @@ pub fn root_as_imu_packet(buf: &[u8]) -> Result Result { - flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_imu_packet(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -472,10 +401,10 @@ pub fn size_prefixed_root_as_imu_packet( /// 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], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -485,49 +414,45 @@ pub fn root_as_imu_packet_with_opts<'b, 'o>( /// 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], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) + flatbuffers::size_prefixed_root_with_opts::>(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::(buf) + flatbuffers::root_unchecked::(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::(buf) + flatbuffers::size_prefixed_root_unchecked::(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) + 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) + 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>, -) { - fbb.finish(root, Some(IMU_PACKET_IDENTIFIER)); +pub fn finish_imu_packet_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( + fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + root: flatbuffers::WIPOffset>) { + 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>, -) { - fbb.finish_size_prefixed(root, Some(IMU_PACKET_IDENTIFIER)); +pub fn finish_size_prefixed_imu_packet_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { + fbb.finish_size_prefixed(root, Some(IMU_PACKET_IDENTIFIER)); } diff --git a/src/ioheader_generated.rs b/src/ioheader_generated.rs index dca5986..403a227 100644 --- a/src/ioheader_generated.rs +++ b/src/ioheader_generated.rs @@ -1,34 +1,26 @@ // automatically generated by the FlatBuffers compiler, do not modify + // @generated -use core::cmp::Ordering; use core::mem; +use core::cmp::Ordering; extern crate flatbuffers; use self::flatbuffers::{EndianScalar, Follow}; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MIN_COMPRESSION: i32 = 0; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MAX_COMPRESSION: i32 = 4; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] #[allow(non_camel_case_types)] pub const ENUM_VALUES_COMPRESSION: [Compression; 5] = [ - Compression::None, - Compression::Lz4, - Compression::Lz4High, - Compression::Zstd, - Compression::ZstdHigh, + Compression::None, + Compression::Lz4, + Compression::Lz4High, + Compression::Zstd, + Compression::ZstdHigh, ]; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] @@ -36,49 +28,49 @@ pub const ENUM_VALUES_COMPRESSION: [Compression; 5] = [ pub struct Compression(pub i32); #[allow(non_upper_case_globals)] impl Compression { - pub const None: Self = Self(0); - pub const Lz4: Self = Self(1); - pub const Lz4High: Self = Self(2); - pub const Zstd: Self = Self(3); - pub const ZstdHigh: Self = Self(4); + pub const None: Self = Self(0); + pub const Lz4: Self = Self(1); + pub const Lz4High: Self = Self(2); + pub const Zstd: Self = Self(3); + pub const ZstdHigh: Self = Self(4); - pub const ENUM_MIN: i32 = 0; - pub const ENUM_MAX: i32 = 4; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::None, - Self::Lz4, - Self::Lz4High, - Self::Zstd, - Self::ZstdHigh, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::None => Some("None"), - Self::Lz4 => Some("Lz4"), - Self::Lz4High => Some("Lz4High"), - Self::Zstd => Some("Zstd"), - Self::ZstdHigh => Some("ZstdHigh"), - _ => None, - } + pub const ENUM_MIN: i32 = 0; + pub const ENUM_MAX: i32 = 4; + pub const ENUM_VALUES: &'static [Self] = &[ + Self::None, + Self::Lz4, + Self::Lz4High, + Self::Zstd, + Self::ZstdHigh, + ]; + /// Returns the variant's name or "" if unknown. + pub fn variant_name(self) -> Option<&'static str> { + match self { + Self::None => Some("None"), + Self::Lz4 => Some("Lz4"), + Self::Lz4High => Some("Lz4High"), + Self::Zstd => Some("Zstd"), + Self::ZstdHigh => Some("ZstdHigh"), + _ => None, } + } } impl core::fmt::Debug for Compression { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - if let Some(name) = self.variant_name() { - f.write_str(name) - } else { - f.write_fmt(format_args!("", self.0)) - } + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + if let Some(name) = self.variant_name() { + f.write_str(name) + } else { + f.write_fmt(format_args!("", self.0)) } + } } impl<'a> flatbuffers::Follow<'a> for Compression { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); - Self(b) - } + type Inner = Self; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self(b) + } } impl flatbuffers::Push for Compression { @@ -90,28 +82,27 @@ impl flatbuffers::Push for Compression { } impl flatbuffers::EndianScalar for Compression { - type Scalar = i32; - #[inline] - fn to_little_endian(self) -> i32 { - self.0.to_le() - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(v: i32) -> Self { - let b = i32::from_le(v); - Self(b) - } + type Scalar = i32; + #[inline] + fn to_little_endian(self) -> i32 { + self.0.to_le() + } + #[inline] + #[allow(clippy::wrong_self_convention)] + fn from_little_endian(v: i32) -> Self { + let b = i32::from_le(v); + Self(b) + } } impl<'a> flatbuffers::Verifiable for Compression { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - i32::run_verifier(v, pos) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + i32::run_verifier(v, pos) + } } impl flatbuffers::SimpleToVerifyInSlice for Compression {} @@ -119,94 +110,75 @@ pub enum IoheaderOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Ioheader<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } impl<'a> flatbuffers::Follow<'a> for Ioheader<'a> { - type Inner = Ioheader<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } + type Inner = Ioheader<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } } impl<'a> Ioheader<'a> { - pub const VT_COMPRESSION: flatbuffers::VOffsetT = 4; - pub const VT_FILE_DATA_POSITION: flatbuffers::VOffsetT = 6; - pub const VT_DESCRIPTION: flatbuffers::VOffsetT = 8; + pub const VT_COMPRESSION: flatbuffers::VOffsetT = 4; + pub const VT_FILE_DATA_POSITION: flatbuffers::VOffsetT = 6; + pub const VT_DESCRIPTION: flatbuffers::VOffsetT = 8; - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Ioheader { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args IoheaderArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = IoheaderBuilder::new(_fbb); - builder.add_file_data_position(args.file_data_position); - if let Some(x) = args.description { - builder.add_description(x); - } - builder.add_compression(args.compression); - builder.finish() - } + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Ioheader { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, + args: &'args IoheaderArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = IoheaderBuilder::new(_fbb); + builder.add_file_data_position(args.file_data_position); + if let Some(x) = args.description { builder.add_description(x); } + builder.add_compression(args.compression); + builder.finish() + } - #[inline] - pub fn compression(&self) -> Compression { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Ioheader::VT_COMPRESSION, Some(Compression::None)) - .unwrap() - } - } - #[inline] - pub fn file_data_position(&self) -> i64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Ioheader::VT_FILE_DATA_POSITION, Some(-1)) - .unwrap() - } - } - #[inline] - pub fn description(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(Ioheader::VT_DESCRIPTION, None) - } - } + + #[inline] + pub fn compression(&self) -> Compression { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Ioheader::VT_COMPRESSION, Some(Compression::None)).unwrap()} + } + #[inline] + pub fn file_data_position(&self) -> i64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Ioheader::VT_FILE_DATA_POSITION, Some(-1)).unwrap()} + } + #[inline] + pub fn description(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Ioheader::VT_DESCRIPTION, None)} + } } impl flatbuffers::Verifiable for Ioheader<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("compression", Self::VT_COMPRESSION, false)? - .visit_field::("file_data_position", Self::VT_FILE_DATA_POSITION, false)? - .visit_field::>( - "description", - Self::VT_DESCRIPTION, - false, - )? - .finish(); - Ok(()) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("compression", Self::VT_COMPRESSION, false)? + .visit_field::("file_data_position", Self::VT_FILE_DATA_POSITION, false)? + .visit_field::>("description", Self::VT_DESCRIPTION, false)? + .finish(); + Ok(()) + } } pub struct IoheaderArgs<'a> { pub compression: Compression, @@ -214,62 +186,56 @@ pub struct IoheaderArgs<'a> { pub description: Option>, } impl<'a> Default for IoheaderArgs<'a> { - #[inline] - fn default() -> Self { - IoheaderArgs { - compression: Compression::None, - file_data_position: -1, - description: None, - } + #[inline] + fn default() -> Self { + IoheaderArgs { + compression: Compression::None, + file_data_position: -1, + description: None, } + } } -pub struct IoheaderBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, +pub struct IoheaderBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b> IoheaderBuilder<'a, 'b> { - #[inline] - pub fn add_compression(&mut self, compression: Compression) { - self.fbb_.push_slot::( - Ioheader::VT_COMPRESSION, - compression, - Compression::None, - ); - } - #[inline] - pub fn add_file_data_position(&mut self, file_data_position: i64) { - self.fbb_ - .push_slot::(Ioheader::VT_FILE_DATA_POSITION, file_data_position, -1); - } - #[inline] - pub fn add_description(&mut self, description: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(Ioheader::VT_DESCRIPTION, description); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> IoheaderBuilder<'a, 'b> { - let start = _fbb.start_table(); - IoheaderBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> IoheaderBuilder<'a, 'b, A> { + #[inline] + pub fn add_compression(&mut self, compression: Compression) { + self.fbb_.push_slot::(Ioheader::VT_COMPRESSION, compression, Compression::None); + } + #[inline] + pub fn add_file_data_position(&mut self, file_data_position: i64) { + self.fbb_.push_slot::(Ioheader::VT_FILE_DATA_POSITION, file_data_position, -1); + } + #[inline] + pub fn add_description(&mut self, description: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(Ioheader::VT_DESCRIPTION, description); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> IoheaderBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + IoheaderBuilder { + fbb_: _fbb, + start_: start, } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } } impl core::fmt::Debug for Ioheader<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Ioheader"); - ds.field("compression", &self.compression()); - ds.field("file_data_position", &self.file_data_position()); - ds.field("description", &self.description()); - ds.finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Ioheader"); + ds.field("compression", &self.compression()); + ds.field("file_data_position", &self.file_data_position()); + ds.field("description", &self.description()); + ds.finish() + } } #[inline] /// Verifies that a buffer of bytes contains a `Ioheader` @@ -279,7 +245,7 @@ impl core::fmt::Debug for Ioheader<'_> { /// previous, unchecked, behavior use /// `root_as_ioheader_unchecked`. pub fn root_as_ioheader(buf: &[u8]) -> Result { - flatbuffers::root::(buf) + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -288,10 +254,8 @@ pub fn root_as_ioheader(buf: &[u8]) -> Result Result { - flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_ioheader(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -301,10 +265,10 @@ pub fn size_prefixed_root_as_ioheader( /// previous, unchecked, behavior use /// `root_as_ioheader_unchecked`. pub fn root_as_ioheader_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -314,49 +278,45 @@ pub fn root_as_ioheader_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_ioheader_unchecked`. pub fn size_prefixed_root_as_ioheader_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a Ioheader and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `Ioheader`. pub unsafe fn root_as_ioheader_unchecked(buf: &[u8]) -> Ioheader { - flatbuffers::root_unchecked::(buf) + flatbuffers::root_unchecked::(buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed Ioheader and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `Ioheader`. pub unsafe fn size_prefixed_root_as_ioheader_unchecked(buf: &[u8]) -> Ioheader { - flatbuffers::size_prefixed_root_unchecked::(buf) + flatbuffers::size_prefixed_root_unchecked::(buf) } pub const IOHEADER_IDENTIFIER: &str = "IOHE"; #[inline] pub fn ioheader_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, IOHEADER_IDENTIFIER, false) + flatbuffers::buffer_has_identifier(buf, IOHEADER_IDENTIFIER, false) } #[inline] pub fn ioheader_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, IOHEADER_IDENTIFIER, true) + flatbuffers::buffer_has_identifier(buf, IOHEADER_IDENTIFIER, true) } #[inline] -pub fn finish_ioheader_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish(root, Some(IOHEADER_IDENTIFIER)); +pub fn finish_ioheader_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( + fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + root: flatbuffers::WIPOffset>) { + fbb.finish(root, Some(IOHEADER_IDENTIFIER)); } #[inline] -pub fn finish_size_prefixed_ioheader_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, Some(IOHEADER_IDENTIFIER)); +pub fn finish_size_prefixed_ioheader_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { + fbb.finish_size_prefixed(root, Some(IOHEADER_IDENTIFIER)); } diff --git a/src/lib.rs b/src/lib.rs index 1f39ab0..bda8c12 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,10 @@ -extern crate ndarray; +mod aedat_core; + use ndarray::IntoDimension; -extern crate numpy; use numpy::convert::ToPyArray; +use numpy::prelude::*; use numpy::Element; -extern crate pyo3; use pyo3::prelude::*; -mod aedat_core; impl std::convert::From for pyo3::PyErr { fn from(error: aedat_core::ParseError) -> Self { @@ -21,7 +20,7 @@ struct Decoder { #[pymethods] impl Decoder { #[new] - fn new(path: &pyo3::types::PyAny) -> Result { + fn new(path: &pyo3::Bound<'_, pyo3::types::PyAny>) -> Result { pyo3::Python::with_gil(|python| -> Result { match python_path_to_string(python, path) { Ok(result) => match aedat_core::Decoder::new(result) { @@ -34,9 +33,9 @@ impl Decoder { } fn id_to_stream(&self, python: pyo3::prelude::Python) -> PyResult { - let python_id_to_stream = pyo3::types::PyDict::new(python); + let python_id_to_stream = pyo3::types::PyDict::new_bound(python); for (id, stream) in self.decoder.id_to_stream.iter() { - let python_stream = pyo3::types::PyDict::new(python); + let python_stream = pyo3::types::PyDict::new_bound(python); match stream.content { aedat_core::StreamContent::Events => { python_stream.set_item("type", "events")?; @@ -71,7 +70,7 @@ impl Decoder { None => return Ok(None), }; pyo3::Python::with_gil(|python| -> PyResult> { - let python_packet = pyo3::types::PyDict::new(python); + let python_packet = pyo3::types::PyDict::new_bound(python); python_packet.set_item("stream_id", packet.stream_id)?; match shell .decoder @@ -107,28 +106,32 @@ impl Decoder { dtype_as_list, 0, "t", - u64::get_dtype(python).num(), + None, + u64::get_dtype_bound(python).num(), ); set_dtype_as_list_field( python, dtype_as_list, 1, "x", - u16::get_dtype(python).num(), + None, + u16::get_dtype_bound(python).num(), ); set_dtype_as_list_field( python, dtype_as_list, 2, "y", - u16::get_dtype(python).num(), + None, + u16::get_dtype_bound(python).num(), ); set_dtype_as_list_field( python, dtype_as_list, 3, "on", - bool::get_dtype(python).num(), + Some("p"), + bool::get_dtype_bound(python).num(), ); let mut dtype: *mut numpy::npyffi::PyArray_Descr = std::ptr::null_mut(); if numpy::PY_ARRAY_API.PyArray_DescrConverter( @@ -160,10 +163,12 @@ impl Decoder { &mut index as *mut numpy::npyffi::npy_intp, ) as *mut u8; let event = events.get(index as usize); - *(event_cell.offset(0) as *mut u64) = event.t() as u64; - *(event_cell.offset(8) as *mut u16) = event.x() as u16; - *(event_cell.offset(10) as *mut u16) = event.y() as u16; - *event_cell.offset(12) = u8::from(event.on()); + let mut event_array = [0u8; 13]; + event_array[0..8].copy_from_slice(&(event.t() as u64).to_ne_bytes()); + event_array[8..10].copy_from_slice(&(event.x() as u16).to_ne_bytes()); + event_array[10..12].copy_from_slice(&(event.y() as u16).to_ne_bytes()); + event_array[12] = if event.on() { 1 } else { 0 }; + std::ptr::copy(event_array.as_ptr(), event_cell, event_array.len()); } PyObject::from_owned_ptr(python, array) })?; @@ -179,7 +184,7 @@ impl Decoder { ))) } }; - let python_frame = pyo3::types::PyDict::new(python); + let python_frame = pyo3::types::PyDict::new_bound(python); python_frame.set_item("t", frame.t())?; python_frame.set_item("begin_t", frame.begin_t())?; python_frame.set_item("end_t", frame.end_t())?; @@ -209,10 +214,11 @@ impl Decoder { python_frame.set_item( "pixels", match frame.pixels() { - Some(result) => { - result.bytes().to_pyarray(python).reshape(dimensions)? - } - None => numpy::array::PyArray2::::zeros( + Some(result) => result + .bytes() + .to_pyarray_bound(python) + .reshape(dimensions)?, + None => numpy::array::PyArray2::::zeros_bound( python, dimensions, false, ), }, @@ -238,9 +244,9 @@ impl Decoder { for index in 0..(pixels.len() / channels) { pixels.swap(index * channels, index * channels + 2); } - pixels.to_pyarray(python).reshape(dimensions)? + pixels.to_pyarray_bound(python).reshape(dimensions)? } - None => numpy::array::PyArray3::::zeros( + None => numpy::array::PyArray3::::zeros_bound( python, dimensions, false, ), }, @@ -280,77 +286,88 @@ impl Decoder { dtype_as_list, 0, "t", - u64::get_dtype(python).num(), + None, + u64::get_dtype_bound(python).num(), ); set_dtype_as_list_field( python, dtype_as_list, 1, "temperature", - f32::get_dtype(python).num(), + None, + f32::get_dtype_bound(python).num(), ); set_dtype_as_list_field( python, dtype_as_list, 2, "accelerometer_x", - f32::get_dtype(python).num(), + None, + f32::get_dtype_bound(python).num(), ); set_dtype_as_list_field( python, dtype_as_list, 3, "accelerometer_y", - f32::get_dtype(python).num(), + None, + f32::get_dtype_bound(python).num(), ); set_dtype_as_list_field( python, dtype_as_list, 4, "accelerometer_z", - f32::get_dtype(python).num(), + None, + f32::get_dtype_bound(python).num(), ); set_dtype_as_list_field( python, dtype_as_list, 5, "gyroscope_x", - f32::get_dtype(python).num(), + None, + f32::get_dtype_bound(python).num(), ); set_dtype_as_list_field( python, dtype_as_list, 6, "gyroscope_y", - f32::get_dtype(python).num(), + None, + f32::get_dtype_bound(python).num(), ); set_dtype_as_list_field( python, dtype_as_list, 7, "gyroscope_z", - f32::get_dtype(python).num(), + None, + f32::get_dtype_bound(python).num(), ); set_dtype_as_list_field( python, dtype_as_list, 8, "magnetometer_x", - f32::get_dtype(python).num(), + None, + f32::get_dtype_bound(python).num(), ); set_dtype_as_list_field( python, dtype_as_list, 9, "magnetometer_y", - f32::get_dtype(python).num(), + None, + f32::get_dtype_bound(python).num(), ); set_dtype_as_list_field( python, dtype_as_list, 10, "magnetometer_z", - f32::get_dtype(python).num(), + None, + f32::get_dtype_bound(python).num(), ); let mut dtype: *mut numpy::npyffi::PyArray_Descr = std::ptr::null_mut(); if numpy::PY_ARRAY_API.PyArray_DescrConverter( @@ -382,17 +399,25 @@ impl Decoder { array as *mut numpy::npyffi::PyArrayObject, &mut index as *mut numpy::npyffi::npy_intp, ) as *mut u8; - *(imu_cell.offset(0) as *mut u64) = imu.t() as u64; - *(imu_cell.offset(8) as *mut f32) = imu.temperature(); - *(imu_cell.offset(12) as *mut f32) = imu.accelerometer_x(); - *(imu_cell.offset(16) as *mut f32) = imu.accelerometer_y(); - *(imu_cell.offset(20) as *mut f32) = imu.accelerometer_z(); - *(imu_cell.offset(24) as *mut f32) = imu.gyroscope_x(); - *(imu_cell.offset(28) as *mut f32) = imu.gyroscope_y(); - *(imu_cell.offset(32) as *mut f32) = imu.gyroscope_z(); - *(imu_cell.offset(36) as *mut f32) = imu.magnetometer_x(); - *(imu_cell.offset(40) as *mut f32) = imu.magnetometer_y(); - *(imu_cell.offset(44) as *mut f32) = imu.magnetometer_z(); + let mut imu_array = [0u8; 48]; + imu_array[0..8].copy_from_slice(&(imu.t() as u64).to_ne_bytes()); + imu_array[8..12].copy_from_slice(&(imu.temperature()).to_ne_bytes()); + imu_array[12..16] + .copy_from_slice(&(imu.accelerometer_x()).to_ne_bytes()); + imu_array[16..20] + .copy_from_slice(&(imu.accelerometer_y()).to_ne_bytes()); + imu_array[20..24] + .copy_from_slice(&(imu.accelerometer_z()).to_ne_bytes()); + imu_array[24..28].copy_from_slice(&(imu.gyroscope_x()).to_ne_bytes()); + imu_array[28..32].copy_from_slice(&(imu.gyroscope_y()).to_ne_bytes()); + imu_array[32..36].copy_from_slice(&(imu.gyroscope_z()).to_ne_bytes()); + imu_array[36..40] + .copy_from_slice(&(imu.magnetometer_x()).to_ne_bytes()); + imu_array[40..44] + .copy_from_slice(&(imu.magnetometer_y()).to_ne_bytes()); + imu_array[44..48] + .copy_from_slice(&(imu.magnetometer_z()).to_ne_bytes()); + std::ptr::copy(imu_array.as_ptr(), imu_cell, imu_array.len()); index += 1_isize; } PyObject::from_owned_ptr(python, array) @@ -425,14 +450,16 @@ impl Decoder { dtype_as_list, 0, "t", - u64::get_dtype(python).num(), + None, + u64::get_dtype_bound(python).num(), ); set_dtype_as_list_field( python, dtype_as_list, 1, "source", - u8::get_dtype(python).num(), + None, + u8::get_dtype_bound(python).num(), ); let mut dtype: *mut numpy::npyffi::PyArray_Descr = std::ptr::null_mut(); if numpy::PY_ARRAY_API.PyArray_DescrConverter( @@ -464,30 +491,33 @@ impl Decoder { array as *mut numpy::npyffi::PyArrayObject, &mut index as *mut numpy::npyffi::npy_intp, ) as *mut u8; - *(trigger_cell.offset(0) as *mut u64) = trigger.t() as u64; - *trigger_cell.offset(8) = match trigger.source() { - aedat_core::triggers_generated::TriggerSource::TimestampReset => 0_u8, - aedat_core::triggers_generated::TriggerSource::ExternalSignalRisingEdge => 1_u8, - aedat_core::triggers_generated::TriggerSource::ExternalSignalFallingEdge => { - 2_u8 - } - aedat_core::triggers_generated::TriggerSource::ExternalSignalPulse => 3_u8, - aedat_core::triggers_generated::TriggerSource::ExternalGeneratorRisingEdge => { - 4_u8 - } - aedat_core::triggers_generated::TriggerSource::ExternalGeneratorFallingEdge => { - 5_u8 - } - aedat_core::triggers_generated::TriggerSource::FrameBegin => 6_u8, - aedat_core::triggers_generated::TriggerSource::FrameEnd => 7_u8, - aedat_core::triggers_generated::TriggerSource::ExposureBegin => 8_u8, - aedat_core::triggers_generated::TriggerSource::ExposureEnd => 9_u8, + + let mut trigger_array = [0u8; 9]; + trigger_array[0..8] + .copy_from_slice(&(trigger.t() as u64).to_ne_bytes()); + use aedat_core::triggers_generated::TriggerSource; + trigger_array[8] = match trigger.source() { + TriggerSource::TimestampReset => 0_u8, + TriggerSource::ExternalSignalRisingEdge => 1_u8, + TriggerSource::ExternalSignalFallingEdge => 2_u8, + TriggerSource::ExternalSignalPulse => 3_u8, + TriggerSource::ExternalGeneratorRisingEdge => 4_u8, + TriggerSource::ExternalGeneratorFallingEdge => 5_u8, + TriggerSource::FrameBegin => 6_u8, + TriggerSource::FrameEnd => 7_u8, + TriggerSource::ExposureBegin => 8_u8, + TriggerSource::ExposureEnd => 9_u8, _ => { return Err(pyo3::PyErr::from(aedat_core::ParseError::new( "unknown trigger source", ))) } }; + std::ptr::copy( + trigger_array.as_ptr(), + trigger_cell, + trigger_array.len(), + ); index += 1_isize; } PyObject::from_owned_ptr(python, array) @@ -504,16 +534,45 @@ unsafe fn set_dtype_as_list_field( list: *mut pyo3::ffi::PyObject, index: i32, name: &str, + title: Option<&str>, numpy_type: core::ffi::c_int, ) { let tuple = pyo3::ffi::PyTuple_New(2); if pyo3::ffi::PyTuple_SetItem( tuple, 0 as pyo3::ffi::Py_ssize_t, - pyo3::ffi::PyUnicode_FromStringAndSize( - name.as_ptr() as *const core::ffi::c_char, - name.len() as pyo3::ffi::Py_ssize_t, - ), + match title { + Some(title) => { + let tuple = pyo3::ffi::PyTuple_New(2); + if pyo3::ffi::PyTuple_SetItem( + tuple, + 0 as pyo3::ffi::Py_ssize_t, + pyo3::ffi::PyUnicode_FromStringAndSize( + name.as_ptr() as *const core::ffi::c_char, + name.len() as pyo3::ffi::Py_ssize_t, + ), + ) < 0 + { + panic!("PyTuple_SetItem 0 failed"); + } + if pyo3::ffi::PyTuple_SetItem( + tuple, + 1 as pyo3::ffi::Py_ssize_t, + pyo3::ffi::PyUnicode_FromStringAndSize( + title.as_ptr() as *const core::ffi::c_char, + title.len() as pyo3::ffi::Py_ssize_t, + ), + ) < 0 + { + panic!("PyTuple_SetItem 1 failed"); + } + tuple + } + None => pyo3::ffi::PyUnicode_FromStringAndSize( + name.as_ptr() as *const core::ffi::c_char, + name.len() as pyo3::ffi::Py_ssize_t, + ), + }, ) < 0 { panic!("PyTuple_SetItem 0 failed"); @@ -533,7 +592,7 @@ unsafe fn set_dtype_as_list_field( fn python_path_to_string( python: pyo3::prelude::Python, - path: &pyo3::types::PyAny, + path: &pyo3::Bound<'_, pyo3::types::PyAny>, ) -> PyResult { if let Ok(result) = path.downcast::() { return Ok(result.to_string()); @@ -553,8 +612,10 @@ fn python_path_to_string( } #[pymodule] -fn aedat(_python: pyo3::prelude::Python, module: &pyo3::prelude::PyModule) -> PyResult<()> { +fn aedat( + _python: pyo3::prelude::Python, + module: &pyo3::Bound<'_, pyo3::types::PyModule>, +) -> PyResult<()> { module.add_class::()?; - Ok(()) } diff --git a/src/triggers_generated.rs b/src/triggers_generated.rs index 6ed6a77..6a2ce18 100644 --- a/src/triggers_generated.rs +++ b/src/triggers_generated.rs @@ -1,39 +1,31 @@ // automatically generated by the FlatBuffers compiler, do not modify + // @generated -use core::cmp::Ordering; use core::mem; +use core::cmp::Ordering; extern crate flatbuffers; use self::flatbuffers::{EndianScalar, Follow}; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MIN_TRIGGER_SOURCE: i8 = 0; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MAX_TRIGGER_SOURCE: i8 = 9; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] #[allow(non_camel_case_types)] pub const ENUM_VALUES_TRIGGER_SOURCE: [TriggerSource; 10] = [ - TriggerSource::TimestampReset, - TriggerSource::ExternalSignalRisingEdge, - TriggerSource::ExternalSignalFallingEdge, - TriggerSource::ExternalSignalPulse, - TriggerSource::ExternalGeneratorRisingEdge, - TriggerSource::ExternalGeneratorFallingEdge, - TriggerSource::FrameBegin, - TriggerSource::FrameEnd, - TriggerSource::ExposureBegin, - TriggerSource::ExposureEnd, + TriggerSource::TimestampReset, + TriggerSource::ExternalSignalRisingEdge, + TriggerSource::ExternalSignalFallingEdge, + TriggerSource::ExternalSignalPulse, + TriggerSource::ExternalGeneratorRisingEdge, + TriggerSource::ExternalGeneratorFallingEdge, + TriggerSource::FrameBegin, + TriggerSource::FrameEnd, + TriggerSource::ExposureBegin, + TriggerSource::ExposureEnd, ]; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] @@ -41,64 +33,64 @@ pub const ENUM_VALUES_TRIGGER_SOURCE: [TriggerSource; 10] = [ pub struct TriggerSource(pub i8); #[allow(non_upper_case_globals)] impl TriggerSource { - pub const TimestampReset: Self = Self(0); - pub const ExternalSignalRisingEdge: Self = Self(1); - pub const ExternalSignalFallingEdge: Self = Self(2); - pub const ExternalSignalPulse: Self = Self(3); - pub const ExternalGeneratorRisingEdge: Self = Self(4); - pub const ExternalGeneratorFallingEdge: Self = Self(5); - pub const FrameBegin: Self = Self(6); - pub const FrameEnd: Self = Self(7); - pub const ExposureBegin: Self = Self(8); - pub const ExposureEnd: Self = Self(9); - - pub const ENUM_MIN: i8 = 0; - pub const ENUM_MAX: i8 = 9; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::TimestampReset, - Self::ExternalSignalRisingEdge, - Self::ExternalSignalFallingEdge, - Self::ExternalSignalPulse, - Self::ExternalGeneratorRisingEdge, - Self::ExternalGeneratorFallingEdge, - Self::FrameBegin, - Self::FrameEnd, - Self::ExposureBegin, - Self::ExposureEnd, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::TimestampReset => Some("TimestampReset"), - Self::ExternalSignalRisingEdge => Some("ExternalSignalRisingEdge"), - Self::ExternalSignalFallingEdge => Some("ExternalSignalFallingEdge"), - Self::ExternalSignalPulse => Some("ExternalSignalPulse"), - Self::ExternalGeneratorRisingEdge => Some("ExternalGeneratorRisingEdge"), - Self::ExternalGeneratorFallingEdge => Some("ExternalGeneratorFallingEdge"), - Self::FrameBegin => Some("FrameBegin"), - Self::FrameEnd => Some("FrameEnd"), - Self::ExposureBegin => Some("ExposureBegin"), - Self::ExposureEnd => Some("ExposureEnd"), - _ => None, - } + pub const TimestampReset: Self = Self(0); + pub const ExternalSignalRisingEdge: Self = Self(1); + pub const ExternalSignalFallingEdge: Self = Self(2); + pub const ExternalSignalPulse: Self = Self(3); + pub const ExternalGeneratorRisingEdge: Self = Self(4); + pub const ExternalGeneratorFallingEdge: Self = Self(5); + pub const FrameBegin: Self = Self(6); + pub const FrameEnd: Self = Self(7); + pub const ExposureBegin: Self = Self(8); + pub const ExposureEnd: Self = Self(9); + + pub const ENUM_MIN: i8 = 0; + pub const ENUM_MAX: i8 = 9; + pub const ENUM_VALUES: &'static [Self] = &[ + Self::TimestampReset, + Self::ExternalSignalRisingEdge, + Self::ExternalSignalFallingEdge, + Self::ExternalSignalPulse, + Self::ExternalGeneratorRisingEdge, + Self::ExternalGeneratorFallingEdge, + Self::FrameBegin, + Self::FrameEnd, + Self::ExposureBegin, + Self::ExposureEnd, + ]; + /// Returns the variant's name or "" if unknown. + pub fn variant_name(self) -> Option<&'static str> { + match self { + Self::TimestampReset => Some("TimestampReset"), + Self::ExternalSignalRisingEdge => Some("ExternalSignalRisingEdge"), + Self::ExternalSignalFallingEdge => Some("ExternalSignalFallingEdge"), + Self::ExternalSignalPulse => Some("ExternalSignalPulse"), + Self::ExternalGeneratorRisingEdge => Some("ExternalGeneratorRisingEdge"), + Self::ExternalGeneratorFallingEdge => Some("ExternalGeneratorFallingEdge"), + Self::FrameBegin => Some("FrameBegin"), + Self::FrameEnd => Some("FrameEnd"), + Self::ExposureBegin => Some("ExposureBegin"), + Self::ExposureEnd => Some("ExposureEnd"), + _ => None, } + } } impl core::fmt::Debug for TriggerSource { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - if let Some(name) = self.variant_name() { - f.write_str(name) - } else { - f.write_fmt(format_args!("", self.0)) - } + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + if let Some(name) = self.variant_name() { + f.write_str(name) + } else { + f.write_fmt(format_args!("", self.0)) } + } } impl<'a> flatbuffers::Follow<'a> for TriggerSource { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); - Self(b) - } + type Inner = Self; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self(b) + } } impl flatbuffers::Push for TriggerSource { @@ -110,28 +102,27 @@ impl flatbuffers::Push for TriggerSource { } impl flatbuffers::EndianScalar for TriggerSource { - type Scalar = i8; - #[inline] - fn to_little_endian(self) -> i8 { - self.0.to_le() - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(v: i8) -> Self { - let b = i8::from_le(v); - Self(b) - } + type Scalar = i8; + #[inline] + fn to_little_endian(self) -> i8 { + self.0.to_le() + } + #[inline] + #[allow(clippy::wrong_self_convention)] + fn from_little_endian(v: i8) -> Self { + let b = i8::from_le(v); + Self(b) + } } impl<'a> flatbuffers::Verifiable for TriggerSource { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - i8::run_verifier(v, pos) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + i8::run_verifier(v, pos) + } } impl flatbuffers::SimpleToVerifyInSlice for TriggerSource {} @@ -139,240 +130,212 @@ pub enum TriggerOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Trigger<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } impl<'a> flatbuffers::Follow<'a> for Trigger<'a> { - type Inner = Trigger<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } + type Inner = Trigger<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } } impl<'a> Trigger<'a> { - pub const VT_T: flatbuffers::VOffsetT = 4; - pub const VT_SOURCE: flatbuffers::VOffsetT = 6; + pub const VT_T: flatbuffers::VOffsetT = 4; + pub const VT_SOURCE: flatbuffers::VOffsetT = 6; - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Trigger { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args TriggerArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = TriggerBuilder::new(_fbb); - builder.add_t(args.t); - builder.add_source(args.source); - builder.finish() - } + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Trigger { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, + args: &'args TriggerArgs + ) -> flatbuffers::WIPOffset> { + let mut builder = TriggerBuilder::new(_fbb); + builder.add_t(args.t); + builder.add_source(args.source); + builder.finish() + } - #[inline] - pub fn t(&self) -> i64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Trigger::VT_T, Some(0)).unwrap() } - } - #[inline] - pub fn source(&self) -> TriggerSource { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Trigger::VT_SOURCE, Some(TriggerSource::TimestampReset)) - .unwrap() - } - } + + #[inline] + pub fn t(&self) -> i64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Trigger::VT_T, Some(0)).unwrap()} + } + #[inline] + pub fn source(&self) -> TriggerSource { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Trigger::VT_SOURCE, Some(TriggerSource::TimestampReset)).unwrap()} + } } impl flatbuffers::Verifiable for Trigger<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("t", Self::VT_T, false)? - .visit_field::("source", Self::VT_SOURCE, false)? - .finish(); - Ok(()) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("t", Self::VT_T, false)? + .visit_field::("source", Self::VT_SOURCE, false)? + .finish(); + Ok(()) + } } pub struct TriggerArgs { pub t: i64, pub source: TriggerSource, } impl<'a> Default for TriggerArgs { - #[inline] - fn default() -> Self { - TriggerArgs { - t: 0, - source: TriggerSource::TimestampReset, - } + #[inline] + fn default() -> Self { + TriggerArgs { + t: 0, + source: TriggerSource::TimestampReset, } + } } -pub struct TriggerBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> TriggerBuilder<'a, 'b> { - #[inline] - pub fn add_t(&mut self, t: i64) { - self.fbb_.push_slot::(Trigger::VT_T, t, 0); - } - #[inline] - pub fn add_source(&mut self, source: TriggerSource) { - self.fbb_.push_slot::( - Trigger::VT_SOURCE, - source, - TriggerSource::TimestampReset, - ); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> TriggerBuilder<'a, 'b> { - let start = _fbb.start_table(); - TriggerBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) +pub struct TriggerBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TriggerBuilder<'a, 'b, A> { + #[inline] + pub fn add_t(&mut self, t: i64) { + self.fbb_.push_slot::(Trigger::VT_T, t, 0); + } + #[inline] + pub fn add_source(&mut self, source: TriggerSource) { + self.fbb_.push_slot::(Trigger::VT_SOURCE, source, TriggerSource::TimestampReset); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TriggerBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + TriggerBuilder { + fbb_: _fbb, + start_: start, } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } } impl core::fmt::Debug for Trigger<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Trigger"); - ds.field("t", &self.t()); - ds.field("source", &self.source()); - ds.finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Trigger"); + ds.field("t", &self.t()); + ds.field("source", &self.source()); + ds.finish() + } } pub enum TriggerPacketOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TriggerPacket<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } impl<'a> flatbuffers::Follow<'a> for TriggerPacket<'a> { - type Inner = TriggerPacket<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } + type Inner = TriggerPacket<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } } impl<'a> TriggerPacket<'a> { - pub const VT_ELEMENTS: flatbuffers::VOffsetT = 4; + pub const VT_ELEMENTS: flatbuffers::VOffsetT = 4; - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - TriggerPacket { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args TriggerPacketArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = TriggerPacketBuilder::new(_fbb); - if let Some(x) = args.elements { - builder.add_elements(x); - } - builder.finish() - } + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + TriggerPacket { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, + args: &'args TriggerPacketArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = TriggerPacketBuilder::new(_fbb); + if let Some(x) = args.elements { builder.add_elements(x); } + builder.finish() + } - #[inline] - pub fn elements( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(TriggerPacket::VT_ELEMENTS, None) - } - } + + #[inline] + pub fn elements(&self) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(TriggerPacket::VT_ELEMENTS, None)} + } } impl flatbuffers::Verifiable for TriggerPacket<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>, - >>("elements", Self::VT_ELEMENTS, false)? - .finish(); - Ok(()) - } + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>>>("elements", Self::VT_ELEMENTS, false)? + .finish(); + Ok(()) + } } pub struct TriggerPacketArgs<'a> { - pub elements: Option< - flatbuffers::WIPOffset>>>, - >, + pub elements: Option>>>>, } impl<'a> Default for TriggerPacketArgs<'a> { - #[inline] - fn default() -> Self { - TriggerPacketArgs { elements: None } + #[inline] + fn default() -> Self { + TriggerPacketArgs { + elements: None, } + } } -pub struct TriggerPacketBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> TriggerPacketBuilder<'a, 'b> { - #[inline] - pub fn add_elements( - &mut self, - elements: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(TriggerPacket::VT_ELEMENTS, elements); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> TriggerPacketBuilder<'a, 'b> { - let start = _fbb.start_table(); - TriggerPacketBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) +pub struct TriggerPacketBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TriggerPacketBuilder<'a, 'b, A> { + #[inline] + pub fn add_elements(&mut self, elements: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(TriggerPacket::VT_ELEMENTS, elements); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TriggerPacketBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + TriggerPacketBuilder { + fbb_: _fbb, + start_: start, } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } } impl core::fmt::Debug for TriggerPacket<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("TriggerPacket"); - ds.field("elements", &self.elements()); - ds.finish() - } + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("TriggerPacket"); + ds.field("elements", &self.elements()); + ds.finish() + } } #[inline] /// Verifies that a buffer of bytes contains a `TriggerPacket` @@ -382,7 +345,7 @@ impl core::fmt::Debug for TriggerPacket<'_> { /// previous, unchecked, behavior use /// `root_as_trigger_packet_unchecked`. pub fn root_as_trigger_packet(buf: &[u8]) -> Result { - flatbuffers::root::(buf) + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -391,10 +354,8 @@ pub fn root_as_trigger_packet(buf: &[u8]) -> Result Result { - flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_trigger_packet(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -404,10 +365,10 @@ pub fn size_prefixed_root_as_trigger_packet( /// previous, unchecked, behavior use /// `root_as_trigger_packet_unchecked`. pub fn root_as_trigger_packet_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -417,49 +378,45 @@ pub fn root_as_trigger_packet_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_trigger_packet_unchecked`. pub fn size_prefixed_root_as_trigger_packet_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a TriggerPacket and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `TriggerPacket`. pub unsafe fn root_as_trigger_packet_unchecked(buf: &[u8]) -> TriggerPacket { - flatbuffers::root_unchecked::(buf) + flatbuffers::root_unchecked::(buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed TriggerPacket and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `TriggerPacket`. pub unsafe fn size_prefixed_root_as_trigger_packet_unchecked(buf: &[u8]) -> TriggerPacket { - flatbuffers::size_prefixed_root_unchecked::(buf) + flatbuffers::size_prefixed_root_unchecked::(buf) } pub const TRIGGER_PACKET_IDENTIFIER: &str = "TRIG"; #[inline] pub fn trigger_packet_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, TRIGGER_PACKET_IDENTIFIER, false) + flatbuffers::buffer_has_identifier(buf, TRIGGER_PACKET_IDENTIFIER, false) } #[inline] pub fn trigger_packet_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, TRIGGER_PACKET_IDENTIFIER, true) + flatbuffers::buffer_has_identifier(buf, TRIGGER_PACKET_IDENTIFIER, true) } #[inline] -pub fn finish_trigger_packet_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish(root, Some(TRIGGER_PACKET_IDENTIFIER)); +pub fn finish_trigger_packet_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( + fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + root: flatbuffers::WIPOffset>) { + fbb.finish(root, Some(TRIGGER_PACKET_IDENTIFIER)); } #[inline] -pub fn finish_size_prefixed_trigger_packet_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, Some(TRIGGER_PACKET_IDENTIFIER)); +pub fn finish_size_prefixed_trigger_packet_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { + fbb.finish_size_prefixed(root, Some(TRIGGER_PACKET_IDENTIFIER)); } diff --git a/test.py b/test.py index bfc9d66..3a46ec0 100644 --- a/test.py +++ b/test.py @@ -1,35 +1,45 @@ -import aedat +import hashlib import pathlib + +import aedat + dirname = pathlib.Path(__file__).resolve().parent -decoder = aedat.Decoder(dirname / 'test_data.aedat4') +decoder = aedat.Decoder(dirname / "test_data.aedat4") assert len(decoder.id_to_stream().keys()) == 4 -assert decoder.id_to_stream()[0]['type'] == 'events' -assert decoder.id_to_stream()[0]['width'] == 346 -assert decoder.id_to_stream()[0]['height'] == 260 -assert decoder.id_to_stream()[1]['type'] == 'frame' -assert decoder.id_to_stream()[1]['width'] == 346 -assert decoder.id_to_stream()[1]['height'] == 260 -assert decoder.id_to_stream()[2]['type'] == 'imus' -assert decoder.id_to_stream()[3]['type'] == 'triggers' -counts = [0, 0, 0, 0] -sizes = [0, 0, 0, 0] +assert decoder.id_to_stream()[0]["type"] == "events" +assert decoder.id_to_stream()[0]["width"] == 346 +assert decoder.id_to_stream()[0]["height"] == 260 +assert decoder.id_to_stream()[1]["type"] == "frame" +assert decoder.id_to_stream()[1]["width"] == 346 +assert decoder.id_to_stream()[1]["height"] == 260 +assert decoder.id_to_stream()[2]["type"] == "imus" +assert decoder.id_to_stream()[3]["type"] == "triggers" +t_hasher = hashlib.sha3_224() +x_hasher = hashlib.sha3_224() +y_hasher = hashlib.sha3_224() +on_hasher = hashlib.sha3_224() +frame_hasher = hashlib.sha3_224() +imus_hasher = hashlib.sha3_224() +triggers_hasher = hashlib.sha3_224() for packet in decoder: - counts[packet['stream_id']] += 1 - if 'events' in packet: - sizes[0] += packet['events'].nbytes - elif 'frame' in packet: - sizes[1] += packet['frame']['pixels'].nbytes - elif 'imus' in packet: - sizes[2] += packet['imus'].nbytes - elif 'triggers' in packet: - sizes[3] += packet['triggers'].nbytes -assert counts[0] == 236 -assert counts[1] == 59 -assert counts[2] == 236 -assert counts[3] == 177 -assert sizes[0] == 1024790 -assert sizes[1] == 5307640 -assert sizes[2] == 113424 -assert sizes[3] == 2124 + if "events" in packet: + events = packet["events"] + t_hasher.update(events["t"].tobytes()) + x_hasher.update(events["x"].tobytes()) + y_hasher.update(events["y"].tobytes()) + on_hasher.update(events["on"].tobytes()) + if "frame" in packet: + frame_hasher.update(packet["frame"]["pixels"].tobytes()) + if "imus" in packet: + imus_hasher.update(packet["imus"].tobytes()) + if "triggers" in packet: + triggers_hasher.update(packet["triggers"].tobytes()) +print(f"{t_hasher.hexdigest()=}") +print(f"{x_hasher.hexdigest()=}") +print(f"{y_hasher.hexdigest()=}") +print(f"{on_hasher.hexdigest()=}") +print(f"{frame_hasher.hexdigest()=}") +print(f"{imus_hasher.hexdigest()=}") +print(f"{triggers_hasher.hexdigest()=}")