diff --git a/schema/NOTICE b/schema/NOTICE new file mode 100644 index 0000000..0edb7bf --- /dev/null +++ b/schema/NOTICE @@ -0,0 +1,26 @@ +The *.fbs files in this directory are copied from HyperHDR +(https://github.com/awawa-dev/HyperHDR, include/flatbuffers/parser/, +commit 3a76dcd, version 24.0.0-beta.0) and are distributed under the +following license: + +MIT License + +Copyright (c) 2020-2026 awawa-dev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/schema/hyperhdr_reply.fbs b/schema/hyperhdr_reply.fbs new file mode 100644 index 0000000..c8f6f9d --- /dev/null +++ b/schema/hyperhdr_reply.fbs @@ -0,0 +1,13 @@ +// Copied verbatim from HyperHDR (https://github.com/awawa-dev/HyperHDR), +// include/flatbuffers/parser/hyperhdr_reply.fbs @ 3a76dcd (24.0.0-beta.0). +// Copyright (c) 2020-2026 awawa-dev. MIT License, see schema/NOTICE. + +namespace hyperhdrnet; + +table Reply { + error:string; + video:int = -1; + registered:int = -1; +} + +root_type Reply; diff --git a/schema/hyperhdr_request.fbs b/schema/hyperhdr_request.fbs new file mode 100644 index 0000000..778ce91 --- /dev/null +++ b/schema/hyperhdr_request.fbs @@ -0,0 +1,50 @@ +// Copied verbatim from HyperHDR (https://github.com/awawa-dev/HyperHDR), +// include/flatbuffers/parser/hyperhdr_request.fbs @ 3a76dcd (24.0.0-beta.0). +// Copyright (c) 2020-2026 awawa-dev. MIT License, see schema/NOTICE. + +namespace hyperhdrnet; + +// A priority value of -1 clears all priorities +table Register { + origin:string (required); + priority:int; +} + +table RawImage { + data:[ubyte]; + width:int = -1; + height:int = -1; +} + +table NV12Image { + data_y:[ubyte]; + data_uv:[ubyte]; + width:int; + height:int; + stride_y:int = 0; + stride_uv:int = 0; +} + +union ImageType {RawImage, NV12Image} + +table Image { + data:ImageType (required); + duration:int = -1; +} + +table Clear { + priority:int; +} + +table Color { + data:int = -1; + duration:int = -1; +} + +union Command {Color, Image, Clear, Register} + +table Request { + command:Command (required); +} + +root_type Request; diff --git a/scripts/regen-fbs.sh b/scripts/regen-fbs.sh new file mode 100755 index 0000000..c2b7ab3 --- /dev/null +++ b/scripts/regen-fbs.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Regenerate Rust code from the HyperHDR flatbuffers schemas. +# The flatc version must match the `flatbuffers` crate version in Cargo.toml. +set -euo pipefail + +root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +out="$root/src/hyperhdr/generated" + +crate_ver="$(grep -E '^flatbuffers\s*=' "$root/Cargo.toml" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')" +flatc_ver="$(flatc --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')" +if [[ "$crate_ver" != "$flatc_ver" ]]; then + echo "flatc $flatc_ver does not match flatbuffers crate $crate_ver" >&2 + exit 1 +fi + +rm -f "$out"/*_generated.rs +mkdir -p "$out" +flatc --rust -o "$out" "$root/schema/hyperhdr_request.fbs" "$root/schema/hyperhdr_reply.fbs" +echo "generated with flatc $flatc_ver:" +ls -1 "$out" diff --git a/src/hyperhdr/generated/hyperhdr_reply_generated.rs b/src/hyperhdr/generated/hyperhdr_reply_generated.rs new file mode 100644 index 0000000..1fd3ebc --- /dev/null +++ b/src/hyperhdr/generated/hyperhdr_reply_generated.rs @@ -0,0 +1,242 @@ +// automatically generated by the FlatBuffers compiler, do not modify +// @generated + +extern crate alloc; + +#[allow(unused_imports, dead_code)] +pub mod hyperhdrnet { + + extern crate alloc; + + pub enum ReplyOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct Reply<'a> { + pub _tab: ::flatbuffers::Table<'a>, + } + + impl<'a> ::flatbuffers::Follow<'a> for Reply<'a> { + type Inner = Reply<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: unsafe { ::flatbuffers::Table::new(buf, loc) }, + } + } + } + + impl<'a> Reply<'a> { + pub const VT_ERROR: ::flatbuffers::VOffsetT = 4; + pub const VT_VIDEO: ::flatbuffers::VOffsetT = 6; + pub const VT_REGISTERED: ::flatbuffers::VOffsetT = 8; + + #[inline] + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + Reply { _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 ReplyArgs<'args>, + ) -> ::flatbuffers::WIPOffset> { + let mut builder = ReplyBuilder::new(_fbb); + builder.add_registered(args.registered); + builder.add_video(args.video); + if let Some(x) = args.error { + builder.add_error(x); + } + builder.finish() + } + + #[inline] + pub fn error(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::<::flatbuffers::ForwardsUOffset<&str>>(Reply::VT_ERROR, None) + } + } + #[inline] + pub fn video(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Reply::VT_VIDEO, Some(-1)).unwrap() } + } + #[inline] + pub fn registered(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(Reply::VT_REGISTERED, Some(-1)) + .unwrap() + } + } + } + + impl ::flatbuffers::Verifiable for Reply<'_> { + #[inline] + fn run_verifier( + v: &mut ::flatbuffers::Verifier, + pos: usize, + ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v.visit_table(pos)? + .visit_field::<::flatbuffers::ForwardsUOffset<&str>>( + "error", + Self::VT_ERROR, + false, + )? + .visit_field::("video", Self::VT_VIDEO, false)? + .visit_field::("registered", Self::VT_REGISTERED, false)? + .finish(); + Ok(()) + } + } + pub struct ReplyArgs<'a> { + pub error: Option<::flatbuffers::WIPOffset<&'a str>>, + pub video: i32, + pub registered: i32, + } + impl<'a> Default for ReplyArgs<'a> { + #[inline] + fn default() -> Self { + ReplyArgs { + error: None, + video: -1, + registered: -1, + } + } + } + + pub struct ReplyBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { + fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, + } + impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ReplyBuilder<'a, 'b, A> { + #[inline] + pub fn add_error(&mut self, error: ::flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::<::flatbuffers::WIPOffset<_>>(Reply::VT_ERROR, error); + } + #[inline] + pub fn add_video(&mut self, video: i32) { + self.fbb_.push_slot::(Reply::VT_VIDEO, video, -1); + } + #[inline] + pub fn add_registered(&mut self, registered: i32) { + self.fbb_ + .push_slot::(Reply::VT_REGISTERED, registered, -1); + } + #[inline] + pub fn new( + _fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + ) -> ReplyBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + ReplyBuilder { + 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 Reply<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut ds = f.debug_struct("Reply"); + ds.field("error", &self.error()); + ds.field("video", &self.video()); + ds.field("registered", &self.registered()); + ds.finish() + } + } + #[inline] + /// Verifies that a buffer of bytes contains a `Reply` + /// and returns it. + /// Note that verification is still experimental and may not + /// catch every error, or be maximally performant. For the + /// previous, unchecked, behavior use + /// `root_as_reply_unchecked`. + pub fn root_as_reply(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::root::(buf) + } + #[inline] + /// Verifies that a buffer of bytes contains a size prefixed + /// `Reply` and returns it. + /// Note that verification is still experimental and may not + /// catch every error, or be maximally performant. For the + /// previous, unchecked, behavior use + /// `size_prefixed_root_as_reply_unchecked`. + pub fn size_prefixed_root_as_reply( + buf: &[u8], + ) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::size_prefixed_root::(buf) + } + #[inline] + /// Verifies, with the given options, that a buffer of bytes + /// contains a `Reply` and returns it. + /// Note that verification is still experimental and may not + /// catch every error, or be maximally performant. For the + /// previous, unchecked, behavior use + /// `root_as_reply_unchecked`. + pub fn root_as_reply_with_opts<'b, 'o>( + opts: &'o ::flatbuffers::VerifierOptions, + buf: &'b [u8], + ) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::root_with_opts::>(opts, buf) + } + #[inline] + /// Verifies, with the given verifier options, that a buffer of + /// bytes contains a size prefixed `Reply` and returns + /// it. Note that verification is still experimental and may not + /// catch every error, or be maximally performant. For the + /// previous, unchecked, behavior use + /// `root_as_reply_unchecked`. + pub fn size_prefixed_root_as_reply_with_opts<'b, 'o>( + opts: &'o ::flatbuffers::VerifierOptions, + buf: &'b [u8], + ) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::size_prefixed_root_with_opts::>(opts, buf) + } + #[inline] + /// Assumes, without verification, that a buffer of bytes contains a Reply and returns it. + /// # Safety + /// Callers must trust the given bytes do indeed contain a valid `Reply`. + pub unsafe fn root_as_reply_unchecked(buf: &[u8]) -> Reply<'_> { + unsafe { ::flatbuffers::root_unchecked::(buf) } + } + #[inline] + /// Assumes, without verification, that a buffer of bytes contains a size prefixed Reply and returns it. + /// # Safety + /// Callers must trust the given bytes do indeed contain a valid size prefixed `Reply`. + pub unsafe fn size_prefixed_root_as_reply_unchecked(buf: &[u8]) -> Reply<'_> { + unsafe { ::flatbuffers::size_prefixed_root_unchecked::(buf) } + } + #[inline] + pub fn finish_reply_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( + fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + root: ::flatbuffers::WIPOffset>, + ) { + fbb.finish(root, None); + } + + #[inline] + pub fn finish_size_prefixed_reply_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( + fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + root: ::flatbuffers::WIPOffset>, + ) { + fbb.finish_size_prefixed(root, None); + } +} // pub mod hyperhdrnet diff --git a/src/hyperhdr/generated/hyperhdr_request_generated.rs b/src/hyperhdr/generated/hyperhdr_request_generated.rs new file mode 100644 index 0000000..2fd1307 --- /dev/null +++ b/src/hyperhdr/generated/hyperhdr_request_generated.rs @@ -0,0 +1,1531 @@ +// automatically generated by the FlatBuffers compiler, do not modify +// @generated + +extern crate alloc; + +#[allow(unused_imports, dead_code)] +pub mod hyperhdrnet { + + extern crate alloc; + + #[deprecated( + since = "2.0.0", + note = "Use associated constants instead. This will no longer be generated in 2021." + )] + pub const ENUM_MIN_IMAGE_TYPE: u8 = 0; + #[deprecated( + since = "2.0.0", + note = "Use associated constants instead. This will no longer be generated in 2021." + )] + pub const ENUM_MAX_IMAGE_TYPE: u8 = 2; + #[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_IMAGE_TYPE: [ImageType; 3] = + [ImageType::NONE, ImageType::RawImage, ImageType::NV12Image]; + + #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] + #[repr(transparent)] + pub struct ImageType(pub u8); + #[allow(non_upper_case_globals)] + impl ImageType { + pub const NONE: Self = Self(0); + pub const RawImage: Self = Self(1); + pub const NV12Image: Self = Self(2); + + pub const ENUM_MIN: u8 = 0; + pub const ENUM_MAX: u8 = 2; + pub const ENUM_VALUES: &'static [Self] = &[Self::NONE, Self::RawImage, Self::NV12Image]; + /// Returns the variant's name or "" if unknown. + pub fn variant_name(self) -> Option<&'static str> { + match self { + Self::NONE => Some("NONE"), + Self::RawImage => Some("RawImage"), + Self::NV12Image => Some("NV12Image"), + _ => None, + } + } + } + impl ::core::fmt::Debug for ImageType { + 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 ImageType { + type Inner = Self; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; + Self(b) + } + } + + impl ::flatbuffers::Push for ImageType { + type Output = ImageType; + #[inline] + unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { + unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; + } + } + + impl ::flatbuffers::EndianScalar for ImageType { + type Scalar = u8; + #[inline] + fn to_little_endian(self) -> u8 { + self.0.to_le() + } + #[inline] + #[allow(clippy::wrong_self_convention)] + fn from_little_endian(v: u8) -> Self { + let b = u8::from_le(v); + Self(b) + } + } + + impl<'a> ::flatbuffers::Verifiable for ImageType { + #[inline] + fn run_verifier( + v: &mut ::flatbuffers::Verifier, + pos: usize, + ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + u8::run_verifier(v, pos) + } + } + + impl ::flatbuffers::SimpleToVerifyInSlice for ImageType {} + pub struct ImageTypeUnionTableOffset {} + + #[deprecated( + since = "2.0.0", + note = "Use associated constants instead. This will no longer be generated in 2021." + )] + pub const ENUM_MIN_COMMAND: u8 = 0; + #[deprecated( + since = "2.0.0", + note = "Use associated constants instead. This will no longer be generated in 2021." + )] + pub const ENUM_MAX_COMMAND: u8 = 4; + #[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_COMMAND: [Command; 5] = [ + Command::NONE, + Command::Color, + Command::Image, + Command::Clear, + Command::Register, + ]; + + #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] + #[repr(transparent)] + pub struct Command(pub u8); + #[allow(non_upper_case_globals)] + impl Command { + pub const NONE: Self = Self(0); + pub const Color: Self = Self(1); + pub const Image: Self = Self(2); + pub const Clear: Self = Self(3); + pub const Register: Self = Self(4); + + pub const ENUM_MIN: u8 = 0; + pub const ENUM_MAX: u8 = 4; + pub const ENUM_VALUES: &'static [Self] = &[ + Self::NONE, + Self::Color, + Self::Image, + Self::Clear, + Self::Register, + ]; + /// Returns the variant's name or "" if unknown. + pub fn variant_name(self) -> Option<&'static str> { + match self { + Self::NONE => Some("NONE"), + Self::Color => Some("Color"), + Self::Image => Some("Image"), + Self::Clear => Some("Clear"), + Self::Register => Some("Register"), + _ => None, + } + } + } + impl ::core::fmt::Debug for Command { + 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 Command { + type Inner = Self; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; + Self(b) + } + } + + impl ::flatbuffers::Push for Command { + type Output = Command; + #[inline] + unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { + unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; + } + } + + impl ::flatbuffers::EndianScalar for Command { + type Scalar = u8; + #[inline] + fn to_little_endian(self) -> u8 { + self.0.to_le() + } + #[inline] + #[allow(clippy::wrong_self_convention)] + fn from_little_endian(v: u8) -> Self { + let b = u8::from_le(v); + Self(b) + } + } + + impl<'a> ::flatbuffers::Verifiable for Command { + #[inline] + fn run_verifier( + v: &mut ::flatbuffers::Verifier, + pos: usize, + ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + u8::run_verifier(v, pos) + } + } + + impl ::flatbuffers::SimpleToVerifyInSlice for Command {} + pub struct CommandUnionTableOffset {} + + pub enum RegisterOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct Register<'a> { + pub _tab: ::flatbuffers::Table<'a>, + } + + impl<'a> ::flatbuffers::Follow<'a> for Register<'a> { + type Inner = Register<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: unsafe { ::flatbuffers::Table::new(buf, loc) }, + } + } + } + + impl<'a> Register<'a> { + pub const VT_ORIGIN: ::flatbuffers::VOffsetT = 4; + pub const VT_PRIORITY: ::flatbuffers::VOffsetT = 6; + + #[inline] + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + Register { _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 RegisterArgs<'args>, + ) -> ::flatbuffers::WIPOffset> { + let mut builder = RegisterBuilder::new(_fbb); + builder.add_priority(args.priority); + if let Some(x) = args.origin { + builder.add_origin(x); + } + builder.finish() + } + + #[inline] + pub fn origin(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::<::flatbuffers::ForwardsUOffset<&str>>(Register::VT_ORIGIN, None) + .unwrap() + } + } + #[inline] + pub fn priority(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(Register::VT_PRIORITY, Some(0)) + .unwrap() + } + } + } + + impl ::flatbuffers::Verifiable for Register<'_> { + #[inline] + fn run_verifier( + v: &mut ::flatbuffers::Verifier, + pos: usize, + ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v.visit_table(pos)? + .visit_field::<::flatbuffers::ForwardsUOffset<&str>>( + "origin", + Self::VT_ORIGIN, + true, + )? + .visit_field::("priority", Self::VT_PRIORITY, false)? + .finish(); + Ok(()) + } + } + pub struct RegisterArgs<'a> { + pub origin: Option<::flatbuffers::WIPOffset<&'a str>>, + pub priority: i32, + } + impl<'a> Default for RegisterArgs<'a> { + #[inline] + fn default() -> Self { + RegisterArgs { + origin: None, // required field + priority: 0, + } + } + } + + pub struct RegisterBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { + fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, + } + impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> RegisterBuilder<'a, 'b, A> { + #[inline] + pub fn add_origin(&mut self, origin: ::flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::<::flatbuffers::WIPOffset<_>>(Register::VT_ORIGIN, origin); + } + #[inline] + pub fn add_priority(&mut self, priority: i32) { + self.fbb_ + .push_slot::(Register::VT_PRIORITY, priority, 0); + } + #[inline] + pub fn new( + _fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + ) -> RegisterBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + RegisterBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> ::flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, Register::VT_ORIGIN, "origin"); + ::flatbuffers::WIPOffset::new(o.value()) + } + } + + impl ::core::fmt::Debug for Register<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut ds = f.debug_struct("Register"); + ds.field("origin", &self.origin()); + ds.field("priority", &self.priority()); + ds.finish() + } + } + pub enum RawImageOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct RawImage<'a> { + pub _tab: ::flatbuffers::Table<'a>, + } + + impl<'a> ::flatbuffers::Follow<'a> for RawImage<'a> { + type Inner = RawImage<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: unsafe { ::flatbuffers::Table::new(buf, loc) }, + } + } + } + + impl<'a> RawImage<'a> { + pub const VT_DATA: ::flatbuffers::VOffsetT = 4; + pub const VT_WIDTH: ::flatbuffers::VOffsetT = 6; + pub const VT_HEIGHT: ::flatbuffers::VOffsetT = 8; + + #[inline] + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + RawImage { _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 RawImageArgs<'args>, + ) -> ::flatbuffers::WIPOffset> { + let mut builder = RawImageBuilder::new(_fbb); + builder.add_height(args.height); + builder.add_width(args.width); + if let Some(x) = args.data { + builder.add_data(x); + } + builder.finish() + } + + #[inline] + pub fn data(&self) -> Option<::flatbuffers::Vector<'a, u8>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>( + RawImage::VT_DATA, + None, + ) + } + } + #[inline] + pub fn width(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(RawImage::VT_WIDTH, Some(-1)).unwrap() } + } + #[inline] + pub fn height(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(RawImage::VT_HEIGHT, Some(-1)).unwrap() } + } + } + + impl ::flatbuffers::Verifiable for RawImage<'_> { + #[inline] + fn run_verifier( + v: &mut ::flatbuffers::Verifier, + pos: usize, + ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v.visit_table(pos)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>( + "data", + Self::VT_DATA, + false, + )? + .visit_field::("width", Self::VT_WIDTH, false)? + .visit_field::("height", Self::VT_HEIGHT, false)? + .finish(); + Ok(()) + } + } + pub struct RawImageArgs<'a> { + pub data: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, + pub width: i32, + pub height: i32, + } + impl<'a> Default for RawImageArgs<'a> { + #[inline] + fn default() -> Self { + RawImageArgs { + data: None, + width: -1, + height: -1, + } + } + } + + pub struct RawImageBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { + fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, + } + impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> RawImageBuilder<'a, 'b, A> { + #[inline] + pub fn add_data(&mut self, data: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b, u8>>) { + self.fbb_ + .push_slot_always::<::flatbuffers::WIPOffset<_>>(RawImage::VT_DATA, data); + } + #[inline] + pub fn add_width(&mut self, width: i32) { + self.fbb_.push_slot::(RawImage::VT_WIDTH, width, -1); + } + #[inline] + pub fn add_height(&mut self, height: i32) { + self.fbb_.push_slot::(RawImage::VT_HEIGHT, height, -1); + } + #[inline] + pub fn new( + _fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + ) -> RawImageBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + RawImageBuilder { + 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 RawImage<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut ds = f.debug_struct("RawImage"); + ds.field("data", &self.data()); + ds.field("width", &self.width()); + ds.field("height", &self.height()); + ds.finish() + } + } + pub enum NV12ImageOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct NV12Image<'a> { + pub _tab: ::flatbuffers::Table<'a>, + } + + impl<'a> ::flatbuffers::Follow<'a> for NV12Image<'a> { + type Inner = NV12Image<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: unsafe { ::flatbuffers::Table::new(buf, loc) }, + } + } + } + + impl<'a> NV12Image<'a> { + pub const VT_DATA_Y: ::flatbuffers::VOffsetT = 4; + pub const VT_DATA_UV: ::flatbuffers::VOffsetT = 6; + pub const VT_WIDTH: ::flatbuffers::VOffsetT = 8; + pub const VT_HEIGHT: ::flatbuffers::VOffsetT = 10; + pub const VT_STRIDE_Y: ::flatbuffers::VOffsetT = 12; + pub const VT_STRIDE_UV: ::flatbuffers::VOffsetT = 14; + + #[inline] + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + NV12Image { _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 NV12ImageArgs<'args>, + ) -> ::flatbuffers::WIPOffset> { + let mut builder = NV12ImageBuilder::new(_fbb); + builder.add_stride_uv(args.stride_uv); + builder.add_stride_y(args.stride_y); + builder.add_height(args.height); + builder.add_width(args.width); + if let Some(x) = args.data_uv { + builder.add_data_uv(x); + } + if let Some(x) = args.data_y { + builder.add_data_y(x); + } + builder.finish() + } + + #[inline] + pub fn data_y(&self) -> Option<::flatbuffers::Vector<'a, u8>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>( + NV12Image::VT_DATA_Y, + None, + ) + } + } + #[inline] + pub fn data_uv(&self) -> Option<::flatbuffers::Vector<'a, u8>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>( + NV12Image::VT_DATA_UV, + None, + ) + } + } + #[inline] + pub fn width(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(NV12Image::VT_WIDTH, Some(0)).unwrap() } + } + #[inline] + pub fn height(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(NV12Image::VT_HEIGHT, Some(0)).unwrap() } + } + #[inline] + pub fn stride_y(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(NV12Image::VT_STRIDE_Y, Some(0)) + .unwrap() + } + } + #[inline] + pub fn stride_uv(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(NV12Image::VT_STRIDE_UV, Some(0)) + .unwrap() + } + } + } + + impl ::flatbuffers::Verifiable for NV12Image<'_> { + #[inline] + fn run_verifier( + v: &mut ::flatbuffers::Verifier, + pos: usize, + ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v.visit_table(pos)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>( + "data_y", + Self::VT_DATA_Y, + false, + )? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>( + "data_uv", + Self::VT_DATA_UV, + false, + )? + .visit_field::("width", Self::VT_WIDTH, false)? + .visit_field::("height", Self::VT_HEIGHT, false)? + .visit_field::("stride_y", Self::VT_STRIDE_Y, false)? + .visit_field::("stride_uv", Self::VT_STRIDE_UV, false)? + .finish(); + Ok(()) + } + } + pub struct NV12ImageArgs<'a> { + pub data_y: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, + pub data_uv: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, + pub width: i32, + pub height: i32, + pub stride_y: i32, + pub stride_uv: i32, + } + impl<'a> Default for NV12ImageArgs<'a> { + #[inline] + fn default() -> Self { + NV12ImageArgs { + data_y: None, + data_uv: None, + width: 0, + height: 0, + stride_y: 0, + stride_uv: 0, + } + } + } + + pub struct NV12ImageBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { + fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, + } + impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> NV12ImageBuilder<'a, 'b, A> { + #[inline] + pub fn add_data_y( + &mut self, + data_y: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b, u8>>, + ) { + self.fbb_ + .push_slot_always::<::flatbuffers::WIPOffset<_>>(NV12Image::VT_DATA_Y, data_y); + } + #[inline] + pub fn add_data_uv( + &mut self, + data_uv: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b, u8>>, + ) { + self.fbb_ + .push_slot_always::<::flatbuffers::WIPOffset<_>>(NV12Image::VT_DATA_UV, data_uv); + } + #[inline] + pub fn add_width(&mut self, width: i32) { + self.fbb_.push_slot::(NV12Image::VT_WIDTH, width, 0); + } + #[inline] + pub fn add_height(&mut self, height: i32) { + self.fbb_.push_slot::(NV12Image::VT_HEIGHT, height, 0); + } + #[inline] + pub fn add_stride_y(&mut self, stride_y: i32) { + self.fbb_ + .push_slot::(NV12Image::VT_STRIDE_Y, stride_y, 0); + } + #[inline] + pub fn add_stride_uv(&mut self, stride_uv: i32) { + self.fbb_ + .push_slot::(NV12Image::VT_STRIDE_UV, stride_uv, 0); + } + #[inline] + pub fn new( + _fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + ) -> NV12ImageBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + NV12ImageBuilder { + 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 NV12Image<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut ds = f.debug_struct("NV12Image"); + ds.field("data_y", &self.data_y()); + ds.field("data_uv", &self.data_uv()); + ds.field("width", &self.width()); + ds.field("height", &self.height()); + ds.field("stride_y", &self.stride_y()); + ds.field("stride_uv", &self.stride_uv()); + ds.finish() + } + } + pub enum ImageOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct Image<'a> { + pub _tab: ::flatbuffers::Table<'a>, + } + + impl<'a> ::flatbuffers::Follow<'a> for Image<'a> { + type Inner = Image<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: unsafe { ::flatbuffers::Table::new(buf, loc) }, + } + } + } + + impl<'a> Image<'a> { + pub const VT_DATA_TYPE: ::flatbuffers::VOffsetT = 4; + pub const VT_DATA: ::flatbuffers::VOffsetT = 6; + pub const VT_DURATION: ::flatbuffers::VOffsetT = 8; + + #[inline] + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + Image { _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 ImageArgs, + ) -> ::flatbuffers::WIPOffset> { + let mut builder = ImageBuilder::new(_fbb); + builder.add_duration(args.duration); + if let Some(x) = args.data { + builder.add_data(x); + } + builder.add_data_type(args.data_type); + builder.finish() + } + + #[inline] + pub fn data_type(&self) -> ImageType { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(Image::VT_DATA_TYPE, Some(ImageType::NONE)) + .unwrap() + } + } + #[inline] + pub fn data(&self) -> ::flatbuffers::Table<'a> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>( + Image::VT_DATA, + None, + ) + .unwrap() + } + } + #[inline] + pub fn duration(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Image::VT_DURATION, Some(-1)).unwrap() } + } + #[inline] + #[allow(non_snake_case)] + pub fn data_as_raw_image(&self) -> Option> { + if self.data_type() == ImageType::RawImage { + let u = self.data(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + Some(unsafe { RawImage::init_from_table(u) }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn data_as_nv12_image(&self) -> Option> { + if self.data_type() == ImageType::NV12Image { + let u = self.data(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + Some(unsafe { NV12Image::init_from_table(u) }) + } else { + None + } + } + } + + impl ::flatbuffers::Verifiable for Image<'_> { + #[inline] + fn run_verifier( + v: &mut ::flatbuffers::Verifier, + pos: usize, + ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v.visit_table(pos)? + .visit_union::( + "data_type", + Self::VT_DATA_TYPE, + "data", + Self::VT_DATA, + true, + |key, v, pos| match key { + ImageType::RawImage => v + .verify_union_variant::<::flatbuffers::ForwardsUOffset>( + "ImageType::RawImage", + pos, + ), + ImageType::NV12Image => v + .verify_union_variant::<::flatbuffers::ForwardsUOffset>( + "ImageType::NV12Image", + pos, + ), + _ => Ok(()), + }, + )? + .visit_field::("duration", Self::VT_DURATION, false)? + .finish(); + Ok(()) + } + } + pub struct ImageArgs { + pub data_type: ImageType, + pub data: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, + pub duration: i32, + } + impl<'a> Default for ImageArgs { + #[inline] + fn default() -> Self { + ImageArgs { + data_type: ImageType::NONE, + data: None, // required field + duration: -1, + } + } + } + + pub struct ImageBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { + fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, + } + impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ImageBuilder<'a, 'b, A> { + #[inline] + pub fn add_data_type(&mut self, data_type: ImageType) { + self.fbb_ + .push_slot::(Image::VT_DATA_TYPE, data_type, ImageType::NONE); + } + #[inline] + pub fn add_data(&mut self, data: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { + self.fbb_ + .push_slot_always::<::flatbuffers::WIPOffset<_>>(Image::VT_DATA, data); + } + #[inline] + pub fn add_duration(&mut self, duration: i32) { + self.fbb_.push_slot::(Image::VT_DURATION, duration, -1); + } + #[inline] + pub fn new( + _fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + ) -> ImageBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + ImageBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> ::flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, Image::VT_DATA, "data"); + ::flatbuffers::WIPOffset::new(o.value()) + } + } + + impl ::core::fmt::Debug for Image<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut ds = f.debug_struct("Image"); + ds.field("data_type", &self.data_type()); + match self.data_type() { + ImageType::RawImage => { + if let Some(x) = self.data_as_raw_image() { + ds.field("data", &x) + } else { + ds.field( + "data", + &"InvalidFlatbuffer: Union discriminant does not match value.", + ) + } + } + ImageType::NV12Image => { + if let Some(x) = self.data_as_nv12_image() { + ds.field("data", &x) + } else { + ds.field( + "data", + &"InvalidFlatbuffer: Union discriminant does not match value.", + ) + } + } + _ => { + let x: Option<()> = None; + ds.field("data", &x) + } + }; + ds.field("duration", &self.duration()); + ds.finish() + } + } + pub enum ClearOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct Clear<'a> { + pub _tab: ::flatbuffers::Table<'a>, + } + + impl<'a> ::flatbuffers::Follow<'a> for Clear<'a> { + type Inner = Clear<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: unsafe { ::flatbuffers::Table::new(buf, loc) }, + } + } + } + + impl<'a> Clear<'a> { + pub const VT_PRIORITY: ::flatbuffers::VOffsetT = 4; + + #[inline] + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + Clear { _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 ClearArgs, + ) -> ::flatbuffers::WIPOffset> { + let mut builder = ClearBuilder::new(_fbb); + builder.add_priority(args.priority); + builder.finish() + } + + #[inline] + pub fn priority(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Clear::VT_PRIORITY, Some(0)).unwrap() } + } + } + + impl ::flatbuffers::Verifiable for Clear<'_> { + #[inline] + fn run_verifier( + v: &mut ::flatbuffers::Verifier, + pos: usize, + ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v.visit_table(pos)? + .visit_field::("priority", Self::VT_PRIORITY, false)? + .finish(); + Ok(()) + } + } + pub struct ClearArgs { + pub priority: i32, + } + impl<'a> Default for ClearArgs { + #[inline] + fn default() -> Self { + ClearArgs { priority: 0 } + } + } + + pub struct ClearBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { + fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, + } + impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ClearBuilder<'a, 'b, A> { + #[inline] + pub fn add_priority(&mut self, priority: i32) { + self.fbb_.push_slot::(Clear::VT_PRIORITY, priority, 0); + } + #[inline] + pub fn new( + _fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + ) -> ClearBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + ClearBuilder { + 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 Clear<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut ds = f.debug_struct("Clear"); + ds.field("priority", &self.priority()); + ds.finish() + } + } + pub enum ColorOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct Color<'a> { + pub _tab: ::flatbuffers::Table<'a>, + } + + impl<'a> ::flatbuffers::Follow<'a> for Color<'a> { + type Inner = Color<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: unsafe { ::flatbuffers::Table::new(buf, loc) }, + } + } + } + + impl<'a> Color<'a> { + pub const VT_DATA: ::flatbuffers::VOffsetT = 4; + pub const VT_DURATION: ::flatbuffers::VOffsetT = 6; + + #[inline] + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + Color { _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 ColorArgs, + ) -> ::flatbuffers::WIPOffset> { + let mut builder = ColorBuilder::new(_fbb); + builder.add_duration(args.duration); + builder.add_data(args.data); + builder.finish() + } + + #[inline] + pub fn data(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Color::VT_DATA, Some(-1)).unwrap() } + } + #[inline] + pub fn duration(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Color::VT_DURATION, Some(-1)).unwrap() } + } + } + + impl ::flatbuffers::Verifiable for Color<'_> { + #[inline] + fn run_verifier( + v: &mut ::flatbuffers::Verifier, + pos: usize, + ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v.visit_table(pos)? + .visit_field::("data", Self::VT_DATA, false)? + .visit_field::("duration", Self::VT_DURATION, false)? + .finish(); + Ok(()) + } + } + pub struct ColorArgs { + pub data: i32, + pub duration: i32, + } + impl<'a> Default for ColorArgs { + #[inline] + fn default() -> Self { + ColorArgs { + data: -1, + duration: -1, + } + } + } + + pub struct ColorBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { + fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, + } + impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ColorBuilder<'a, 'b, A> { + #[inline] + pub fn add_data(&mut self, data: i32) { + self.fbb_.push_slot::(Color::VT_DATA, data, -1); + } + #[inline] + pub fn add_duration(&mut self, duration: i32) { + self.fbb_.push_slot::(Color::VT_DURATION, duration, -1); + } + #[inline] + pub fn new( + _fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + ) -> ColorBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + ColorBuilder { + 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 Color<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut ds = f.debug_struct("Color"); + ds.field("data", &self.data()); + ds.field("duration", &self.duration()); + ds.finish() + } + } + pub enum RequestOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct Request<'a> { + pub _tab: ::flatbuffers::Table<'a>, + } + + impl<'a> ::flatbuffers::Follow<'a> for Request<'a> { + type Inner = Request<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: unsafe { ::flatbuffers::Table::new(buf, loc) }, + } + } + } + + impl<'a> Request<'a> { + pub const VT_COMMAND_TYPE: ::flatbuffers::VOffsetT = 4; + pub const VT_COMMAND: ::flatbuffers::VOffsetT = 6; + + #[inline] + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + Request { _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 RequestArgs, + ) -> ::flatbuffers::WIPOffset> { + let mut builder = RequestBuilder::new(_fbb); + if let Some(x) = args.command { + builder.add_command(x); + } + builder.add_command_type(args.command_type); + builder.finish() + } + + #[inline] + pub fn command_type(&self) -> Command { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(Request::VT_COMMAND_TYPE, Some(Command::NONE)) + .unwrap() + } + } + #[inline] + pub fn command(&self) -> ::flatbuffers::Table<'a> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>( + Request::VT_COMMAND, + None, + ) + .unwrap() + } + } + #[inline] + #[allow(non_snake_case)] + pub fn command_as_color(&self) -> Option> { + if self.command_type() == Command::Color { + let u = self.command(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + Some(unsafe { Color::init_from_table(u) }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn command_as_image(&self) -> Option> { + if self.command_type() == Command::Image { + let u = self.command(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + Some(unsafe { Image::init_from_table(u) }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn command_as_clear(&self) -> Option> { + if self.command_type() == Command::Clear { + let u = self.command(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + Some(unsafe { Clear::init_from_table(u) }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn command_as_register(&self) -> Option> { + if self.command_type() == Command::Register { + let u = self.command(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + Some(unsafe { Register::init_from_table(u) }) + } else { + None + } + } + } + + impl ::flatbuffers::Verifiable for Request<'_> { + #[inline] + fn run_verifier( + v: &mut ::flatbuffers::Verifier, + pos: usize, + ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v.visit_table(pos)? + .visit_union::( + "command_type", + Self::VT_COMMAND_TYPE, + "command", + Self::VT_COMMAND, + true, + |key, v, pos| match key { + Command::Color => v + .verify_union_variant::<::flatbuffers::ForwardsUOffset>( + "Command::Color", + pos, + ), + Command::Image => v + .verify_union_variant::<::flatbuffers::ForwardsUOffset>( + "Command::Image", + pos, + ), + Command::Clear => v + .verify_union_variant::<::flatbuffers::ForwardsUOffset>( + "Command::Clear", + pos, + ), + Command::Register => v + .verify_union_variant::<::flatbuffers::ForwardsUOffset>( + "Command::Register", + pos, + ), + _ => Ok(()), + }, + )? + .finish(); + Ok(()) + } + } + pub struct RequestArgs { + pub command_type: Command, + pub command: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, + } + impl<'a> Default for RequestArgs { + #[inline] + fn default() -> Self { + RequestArgs { + command_type: Command::NONE, + command: None, // required field + } + } + } + + pub struct RequestBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { + fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, + } + impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> RequestBuilder<'a, 'b, A> { + #[inline] + pub fn add_command_type(&mut self, command_type: Command) { + self.fbb_ + .push_slot::(Request::VT_COMMAND_TYPE, command_type, Command::NONE); + } + #[inline] + pub fn add_command( + &mut self, + command: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>, + ) { + self.fbb_ + .push_slot_always::<::flatbuffers::WIPOffset<_>>(Request::VT_COMMAND, command); + } + #[inline] + pub fn new( + _fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + ) -> RequestBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + RequestBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> ::flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, Request::VT_COMMAND, "command"); + ::flatbuffers::WIPOffset::new(o.value()) + } + } + + impl ::core::fmt::Debug for Request<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut ds = f.debug_struct("Request"); + ds.field("command_type", &self.command_type()); + match self.command_type() { + Command::Color => { + if let Some(x) = self.command_as_color() { + ds.field("command", &x) + } else { + ds.field( + "command", + &"InvalidFlatbuffer: Union discriminant does not match value.", + ) + } + } + Command::Image => { + if let Some(x) = self.command_as_image() { + ds.field("command", &x) + } else { + ds.field( + "command", + &"InvalidFlatbuffer: Union discriminant does not match value.", + ) + } + } + Command::Clear => { + if let Some(x) = self.command_as_clear() { + ds.field("command", &x) + } else { + ds.field( + "command", + &"InvalidFlatbuffer: Union discriminant does not match value.", + ) + } + } + Command::Register => { + if let Some(x) = self.command_as_register() { + ds.field("command", &x) + } else { + ds.field( + "command", + &"InvalidFlatbuffer: Union discriminant does not match value.", + ) + } + } + _ => { + let x: Option<()> = None; + ds.field("command", &x) + } + }; + ds.finish() + } + } + #[inline] + /// Verifies that a buffer of bytes contains a `Request` + /// and returns it. + /// Note that verification is still experimental and may not + /// catch every error, or be maximally performant. For the + /// previous, unchecked, behavior use + /// `root_as_request_unchecked`. + pub fn root_as_request(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::root::(buf) + } + #[inline] + /// Verifies that a buffer of bytes contains a size prefixed + /// `Request` and returns it. + /// Note that verification is still experimental and may not + /// catch every error, or be maximally performant. For the + /// previous, unchecked, behavior use + /// `size_prefixed_root_as_request_unchecked`. + pub fn size_prefixed_root_as_request( + buf: &[u8], + ) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::size_prefixed_root::(buf) + } + #[inline] + /// Verifies, with the given options, that a buffer of bytes + /// contains a `Request` and returns it. + /// Note that verification is still experimental and may not + /// catch every error, or be maximally performant. For the + /// previous, unchecked, behavior use + /// `root_as_request_unchecked`. + pub fn root_as_request_with_opts<'b, 'o>( + opts: &'o ::flatbuffers::VerifierOptions, + buf: &'b [u8], + ) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::root_with_opts::>(opts, buf) + } + #[inline] + /// Verifies, with the given verifier options, that a buffer of + /// bytes contains a size prefixed `Request` and returns + /// it. Note that verification is still experimental and may not + /// catch every error, or be maximally performant. For the + /// previous, unchecked, behavior use + /// `root_as_request_unchecked`. + pub fn size_prefixed_root_as_request_with_opts<'b, 'o>( + opts: &'o ::flatbuffers::VerifierOptions, + buf: &'b [u8], + ) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::size_prefixed_root_with_opts::>(opts, buf) + } + #[inline] + /// Assumes, without verification, that a buffer of bytes contains a Request and returns it. + /// # Safety + /// Callers must trust the given bytes do indeed contain a valid `Request`. + pub unsafe fn root_as_request_unchecked(buf: &[u8]) -> Request<'_> { + unsafe { ::flatbuffers::root_unchecked::(buf) } + } + #[inline] + /// Assumes, without verification, that a buffer of bytes contains a size prefixed Request and returns it. + /// # Safety + /// Callers must trust the given bytes do indeed contain a valid size prefixed `Request`. + pub unsafe fn size_prefixed_root_as_request_unchecked(buf: &[u8]) -> Request<'_> { + unsafe { ::flatbuffers::size_prefixed_root_unchecked::(buf) } + } + #[inline] + pub fn finish_request_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( + fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + root: ::flatbuffers::WIPOffset>, + ) { + fbb.finish(root, None); + } + + #[inline] + pub fn finish_size_prefixed_request_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( + fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + root: ::flatbuffers::WIPOffset>, + ) { + fbb.finish_size_prefixed(root, None); + } +} // pub mod hyperhdrnet diff --git a/src/hyperhdr/generated/mod.rs b/src/hyperhdr/generated/mod.rs new file mode 100644 index 0000000..6419c6a --- /dev/null +++ b/src/hyperhdr/generated/mod.rs @@ -0,0 +1,22 @@ +//! Code generated by `flatc --rust` from `schema/*.fbs` (see `scripts/regen-fbs.sh`). +//! Only this file is hand-written. + +#![allow( + clippy::all, + dead_code, + unused_imports, + non_camel_case_types, + non_snake_case, + unsafe_op_in_unsafe_fn +)] + +mod hyperhdr_reply_generated; +mod hyperhdr_request_generated; + +pub mod request { + pub use super::hyperhdr_request_generated::hyperhdrnet::*; +} + +pub mod reply { + pub use super::hyperhdr_reply_generated::hyperhdrnet::*; +} diff --git a/src/hyperhdr/mod.rs b/src/hyperhdr/mod.rs new file mode 100644 index 0000000..ae54c69 --- /dev/null +++ b/src/hyperhdr/mod.rs @@ -0,0 +1,3 @@ +//! Client for the HyperHDR flatbuffers server. + +pub mod generated; diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..d1cc1ff --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,4 @@ +//! Captures gamescope's PipeWire stream at a small `requested_size` and forwards it to +//! HyperHDR's flatbuffers server. + +pub mod hyperhdr;