feat(hyperhdr): vendor the flatbuffers schemas and generated bindings
The .fbs files come from HyperHDR (see schema/NOTICE); the *_generated.rs files are flatc output regenerated by scripts/regen-fbs.sh, which refuses to run unless flatc matches the pinned flatbuffers crate.
This commit is contained in:
@@ -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.
|
||||||
@@ -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;
|
||||||
@@ -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;
|
||||||
Executable
+20
@@ -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"
|
||||||
@@ -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<Reply<'bldr>> {
|
||||||
|
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::<i32>(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::<i32>(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::<i32>("video", Self::VT_VIDEO, false)?
|
||||||
|
.visit_field::<i32>("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::<i32>(Reply::VT_VIDEO, video, -1);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn add_registered(&mut self, registered: i32) {
|
||||||
|
self.fbb_
|
||||||
|
.push_slot::<i32>(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<Reply<'a>> {
|
||||||
|
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<Reply<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
::flatbuffers::root::<Reply>(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<Reply<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
::flatbuffers::size_prefixed_root::<Reply>(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<Reply<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
::flatbuffers::root_with_opts::<Reply<'b>>(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<Reply<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
::flatbuffers::size_prefixed_root_with_opts::<Reply<'b>>(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::<Reply>(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::<Reply>(buf) }
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn finish_reply_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
|
||||||
|
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
|
root: ::flatbuffers::WIPOffset<Reply<'a>>,
|
||||||
|
) {
|
||||||
|
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<Reply<'a>>,
|
||||||
|
) {
|
||||||
|
fbb.finish_size_prefixed(root, None);
|
||||||
|
}
|
||||||
|
} // pub mod hyperhdrnet
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -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::*;
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
//! Client for the HyperHDR flatbuffers server.
|
||||||
|
|
||||||
|
pub mod generated;
|
||||||
@@ -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;
|
||||||
Reference in New Issue
Block a user