diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 53b9837..6c7584d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,7 +13,8 @@ "extensions": [ "vadimcn.vscode-lldb", "fill-labs.dependi", - "rust-lang.rust-analyzer" + "rust-lang.rust-analyzer", + "gaborv.flatbuffers" ] } }, diff --git a/.github/docker/Dockerfile.build b/.github/docker/Dockerfile.build index 22aac88..cc9f3d4 100644 --- a/.github/docker/Dockerfile.build +++ b/.github/docker/Dockerfile.build @@ -1,16 +1,48 @@ -# Stage: Bonsol Test +# Stage 1: flatc build +FROM debian:stable-slim AS flatc-build +RUN export DEBIAN_FRONTEND=noninteractive && \ + apt-get update && \ + apt-get install -y -q --no-install-recommends \ + build-essential \ + cmake \ + ca-certificates \ + curl \ + git \ + gnupg2 \ + && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# flatc +WORKDIR /flatbuffers +ARG FLATC_VERSION=24.3.25 +ADD https://github.com/google/flatbuffers/archive/refs/tags/v${FLATC_VERSION}.tar.gz v${FLATC_VERSION}.tar.gz +RUN tar -zxvf v${FLATC_VERSION}.tar.gz || { echo "Failed to extract tarball"; exit 1; } +WORKDIR /flatbuffers/flatbuffers-${FLATC_VERSION} +RUN cmake -G "Unix Makefiles" && make -j && make install +RUN strip /usr/local/bin/flatc + +# Stage 2: Bonsol Test FROM ghcr.io/anagrambuild/risczero:latest +# flatbuffers +COPY --from=flatc-build /usr/local/bin/flatc /usr/local/bin/flatc +COPY --from=flatc-build /usr/local/include/flatbuffers /usr/local/include/flatbuffers +COPY --from=flatc-build /usr/local/lib/libflatbuffers.a /usr/local/lib/libflatbuffers.a +COPY --from=flatc-build /usr/local/lib/cmake/flatbuffers /usr/local/lib/cmake/flatbuffers +COPY --from=flatc-build /usr/local/lib/pkgconfig/flatbuffers.pc /usr/local/lib/pkgconfig/flatbuffers.pc + + ENV USER=solana ARG SOLANA=1.18.22 ENV CARGO_HOME=/usr/local/cargo ENV RUSTUP_HOME=/usr/local/rustup -ENV PATH=${PATH}:/usr/local/cargo/bin:/go/bin:/home/solana/.local/share/solana/install/releases/${SOLANA}/bin -USER solana +ENV PATH=${PATH}:/usr/local/cargo/bin:/go/bin:/home/${USER}/.local/share/solana/install/releases/${SOLANA}/bin # Set user and working directory ARG PACKAGE=bonsol WORKDIR /workspaces/${PACKAGE} +USER solana # Install Rust components RUN rustup component add \ @@ -19,9 +51,10 @@ RUN rustup component add \ RUN rustup toolchain install nightly && \ rustup component add rustfmt --toolchain nightly -COPY . . +COPY --chown=${USER}:${USER} . . RUN /go/bin/yamlfmt -lint .github/workflows/*.yaml .github/workflows/*.yml .github/*.yaml .github/*.yml +RUN cargo check RUN cargo +nightly fmt --all -- --check RUN cargo test diff --git a/.gitignore b/.gitignore index 4fdf8f4..4f48de5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ charts/bonsol-node/alloy.yaml relay/MyLogFile.log NodeDragon.toml images/**/manifest.json -stark \ No newline at end of file +stark +*_generated.rs diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..c1345a0 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1 @@ +ignore = ["**/*_generated.rs"] \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 1e0ac8b..cf38fc0 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,7 +6,7 @@ { "label": "fmt", "type": "shell", - "command": "cargo +nightly fmt --check", + "command": "cargo +nightly fmt --all -- --check", "options": { "cwd": "${workspaceFolder}" }, diff --git a/CHANGELOG.md b/CHANGELOG.md index f9a7803..85b51b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed * `risc0-groth16-prover` binaries (rapidsnark & stark-verify) are available to the nix store, partially unblocking NixOS support. +* `flatbuffers` code is now dynamically generated at build time ## [0.2.1] - 2024-10-13 diff --git a/Cargo.lock b/Cargo.lock index 053b2b8..90e586c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "Inflector" diff --git a/Cargo.toml b/Cargo.toml index 9551cd3..bcab2c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ members = [ "schemas-rust", "cli", "sdk", - "prover", + "prover" ] resolver = "2" # Only necessary for nix cargo workspace artifacts to build without warnings. diff --git a/Dockerfile b/Dockerfile index ee04297..dab4394 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,15 @@ # Stage 1: Node setup FROM debian:stable-slim AS node-slim RUN export DEBIAN_FRONTEND=noninteractive && \ - apt update && \ - apt install -y -q --no-install-recommends \ - build-essential git gnupg2 curl \ - ca-certificates && \ - apt clean && \ - rm -rf /var/lib/apt/lists/* + apt-get update && \ + apt-get install -y -q --no-install-recommends \ + ca-certificates \ + curl \ + git \ + gnupg2 \ + && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ENV NODE_VERSION=v22.3.0 ENV NVM_DIR=/usr/local/nvm @@ -17,9 +20,40 @@ RUN mkdir -p ${NVM_DIR} ADD https://raw.githubusercontent.com/creationix/nvm/master/install.sh /usr/local/etc/nvm/install.sh RUN bash /usr/local/etc/nvm/install.sh +# Stage 2: flatc build +FROM debian:stable-slim AS flatc-build +RUN export DEBIAN_FRONTEND=noninteractive && \ + apt-get update && \ + apt-get install -y -q --no-install-recommends \ + build-essential \ + cmake \ + ca-certificates \ + curl \ + git \ + gnupg2 \ + && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# flatc +WORKDIR /flatbuffers +ARG FLATC_VERSION=24.3.25 +ADD https://github.com/google/flatbuffers/archive/refs/tags/v${FLATC_VERSION}.tar.gz v${FLATC_VERSION}.tar.gz +RUN tar -zxvf v${FLATC_VERSION}.tar.gz || { echo "Failed to extract tarball"; exit 1; } +WORKDIR /flatbuffers/flatbuffers-${FLATC_VERSION} +RUN cmake -G "Unix Makefiles" && make -j && make install +RUN strip /usr/local/bin/flatc + # Stage 2: Bonsol Dev FROM ghcr.io/anagrambuild/risczero:latest +# flatbuffers +COPY --from=flatc-build /usr/local/bin/flatc /usr/local/bin/flatc +COPY --from=flatc-build /usr/local/include/flatbuffers /usr/local/include/flatbuffers +COPY --from=flatc-build /usr/local/lib/libflatbuffers.a /usr/local/lib/libflatbuffers.a +COPY --from=flatc-build /usr/local/lib/cmake/flatbuffers /usr/local/lib/cmake/flatbuffers +COPY --from=flatc-build /usr/local/lib/pkgconfig/flatbuffers.pc /usr/local/lib/pkgconfig/flatbuffers.pc + ENV USER=solana ARG SOLANA=1.18.22 ENV CARGO_HOME=/usr/local/cargo @@ -48,6 +82,7 @@ ENV PATH ${NVM_NODE_PATH}/bin:$PATH COPY --from=node-slim --chown=${USER}:${USER} /usr/local/nvm /usr/local/nvm RUN bash -c ". $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm alias default $NODE_VERSION && nvm use default" + RUN npm install npm -g RUN npm install yarn -g diff --git a/bin/gen.sh b/bin/gen.sh index e6cc1e3..84ac1bc 100755 --- a/bin/gen.sh +++ b/bin/gen.sh @@ -1,5 +1,16 @@ #!/bin/bash -flatc --rust --gen-object-api --gen-mutable --reflect-names -o schemas-rust/src schemas/*.fbs + + +if [ ! -d "schemas" ]; then + echo "No schemas directory found" + exit 1 +fi + +if [ ! -x $(which flatc) ]; then + echo "Flatbuffers compiler is required" + exit 1 +fi + flatc --ts --gen-object-api --gen-mutable --reflect-names -o schemas-ts schemas/*.fbs sed -i.bak ' /mutate_writable(value:boolean):boolean {/,/}/ { diff --git a/schemas-rust/build.rs b/schemas-rust/build.rs new file mode 100644 index 0000000..add7d34 --- /dev/null +++ b/schemas-rust/build.rs @@ -0,0 +1,60 @@ +use std::env; +use std::fs; +use std::path::{Path, PathBuf}; +use std::process::Command; + +fn main() { + // Define schema directory and target directory for generated Rust code. + let schema_dir = Path::new("../schemas"); + let generated_src = + PathBuf::from(env::var("GENERATED_CODE_DIR").unwrap_or_else(|_| "src".to_string())); + + // Collect all .fbs files in the schema directory. + let file_list: Vec<_> = fs::read_dir(&schema_dir) + .expect("Schema directory not found") + .filter_map(|entry| { + entry.ok().and_then(|e| { + let path = e.path(); + if path.extension().and_then(|ext| ext.to_str()) == Some("fbs") { + Some(path) + } else { + None + } + }) + }) + .collect(); + + // Build flatc arguments. + let mut args = vec![ + "--gen-mutable", + "--gen-object-api", + "--reflect-names", + "--rust", + "-o", + generated_src + .to_str() + .expect("Invalid path for generated source"), + ]; + + // Add schema file paths to the arguments. + args.extend(file_list.iter().map(|path| path.to_str().unwrap())); + + // Execute flatc. + let compile_status = Command::new("flatc") + .args(&args) + .status() + .expect("Failed to execute flatc command"); + + assert!( + compile_status.success(), + "flatc failed to compile schema files: {:?}", + file_list + ); + + // Set an environment variable with the generated source path, stripping "src/" if present. + let generated_path = generated_src.strip_prefix("src").unwrap_or(&generated_src); + println!("cargo:rustc-env=GENERATED_SRC={}", generated_path.display()); + + // Instruct Cargo to re-run this script if schema files change. + println!("cargo:rerun-if-changed={}", schema_dir.display()); +} diff --git a/schemas-rust/src/channel_instruction_generated.rs b/schemas-rust/src/channel_instruction_generated.rs deleted file mode 100644 index fd46074..0000000 --- a/schemas-rust/src/channel_instruction_generated.rs +++ /dev/null @@ -1,598 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -// @generated - -use crate::claim_v1_generated::*; -use crate::deploy_v1_generated::*; -use crate::execution_request_v1_generated::*; -use crate::input_set_op_v1_generated::*; -use crate::input_type_generated::*; -use crate::status_v1_generated::*; -use core::cmp::Ordering; -use core::mem; - -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." -)] -pub const ENUM_MIN_CHANNEL_INSTRUCTION_IX_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_CHANNEL_INSTRUCTION_IX_TYPE: 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_CHANNEL_INSTRUCTION_IX_TYPE: [ChannelInstructionIxType; 5] = [ - ChannelInstructionIxType::ExecuteV1, - ChannelInstructionIxType::StatusV1, - ChannelInstructionIxType::DeployV1, - ChannelInstructionIxType::ClaimV1, - ChannelInstructionIxType::InputSetOpV1, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct ChannelInstructionIxType(pub u8); -#[allow(non_upper_case_globals)] -impl ChannelInstructionIxType { - pub const ExecuteV1: Self = Self(0); - pub const StatusV1: Self = Self(1); - pub const DeployV1: Self = Self(2); - pub const ClaimV1: Self = Self(3); - pub const InputSetOpV1: Self = Self(4); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 4; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::ExecuteV1, - Self::StatusV1, - Self::DeployV1, - Self::ClaimV1, - Self::InputSetOpV1, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::ExecuteV1 => Some("ExecuteV1"), - Self::StatusV1 => Some("StatusV1"), - Self::DeployV1 => Some("DeployV1"), - Self::ClaimV1 => Some("ClaimV1"), - Self::InputSetOpV1 => Some("InputSetOpV1"), - _ => None, - } - } -} -impl core::fmt::Debug for ChannelInstructionIxType { - 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 ChannelInstructionIxType { - 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 ChannelInstructionIxType { - type Output = ChannelInstructionIxType; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); - } -} - -impl flatbuffers::EndianScalar for ChannelInstructionIxType { - 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 ChannelInstructionIxType { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - u8::run_verifier(v, pos) - } -} - -impl flatbuffers::SimpleToVerifyInSlice for ChannelInstructionIxType {} -pub enum ChannelInstructionOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct ChannelInstruction<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for ChannelInstruction<'a> { - type Inner = ChannelInstruction<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } -} - -impl<'a> ChannelInstruction<'a> { - pub const VT_IX_TYPE: flatbuffers::VOffsetT = 4; - pub const VT_EXECUTE_V1: flatbuffers::VOffsetT = 6; - pub const VT_STATUS_V1: flatbuffers::VOffsetT = 8; - pub const VT_DEPLOY_V1: flatbuffers::VOffsetT = 10; - pub const VT_CLAIM_V1: flatbuffers::VOffsetT = 12; - pub const VT_INPUT_SET_V1: flatbuffers::VOffsetT = 14; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - ChannelInstruction { _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 ChannelInstructionArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = ChannelInstructionBuilder::new(_fbb); - if let Some(x) = args.input_set_v1 { - builder.add_input_set_v1(x); - } - if let Some(x) = args.claim_v1 { - builder.add_claim_v1(x); - } - if let Some(x) = args.deploy_v1 { - builder.add_deploy_v1(x); - } - if let Some(x) = args.status_v1 { - builder.add_status_v1(x); - } - if let Some(x) = args.execute_v1 { - builder.add_execute_v1(x); - } - builder.add_ix_type(args.ix_type); - builder.finish() - } - - pub fn unpack(&self) -> ChannelInstructionT { - let ix_type = self.ix_type(); - let execute_v1 = self.execute_v1().map(|x| x.into_iter().collect()); - let status_v1 = self.status_v1().map(|x| x.into_iter().collect()); - let deploy_v1 = self.deploy_v1().map(|x| x.into_iter().collect()); - let claim_v1 = self.claim_v1().map(|x| x.into_iter().collect()); - let input_set_v1 = self.input_set_v1().map(|x| x.into_iter().collect()); - ChannelInstructionT { - ix_type, - execute_v1, - status_v1, - deploy_v1, - claim_v1, - input_set_v1, - } - } - - #[inline] - pub fn ix_type(&self) -> ChannelInstructionIxType { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::( - ChannelInstruction::VT_IX_TYPE, - Some(ChannelInstructionIxType::ExecuteV1), - ) - .unwrap() - } - } - #[inline] - pub fn execute_v1(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - ChannelInstruction::VT_EXECUTE_V1, - None, - ) - } - } - pub fn execute_v1_nested_flatbuffer(&'a self) -> Option> { - self.execute_v1().map(|data| { - use flatbuffers::Follow; - // Safety: - // Created from a valid Table for this object - // Which contains a valid flatbuffer in this slot - unsafe { - >>::follow(data.bytes(), 0) - } - }) - } - #[inline] - pub fn status_v1(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - ChannelInstruction::VT_STATUS_V1, - None, - ) - } - } - pub fn status_v1_nested_flatbuffer(&'a self) -> Option> { - self.status_v1().map(|data| { - use flatbuffers::Follow; - // Safety: - // Created from a valid Table for this object - // Which contains a valid flatbuffer in this slot - unsafe { >>::follow(data.bytes(), 0) } - }) - } - #[inline] - pub fn deploy_v1(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - ChannelInstruction::VT_DEPLOY_V1, - None, - ) - } - } - pub fn deploy_v1_nested_flatbuffer(&'a self) -> Option> { - self.deploy_v1().map(|data| { - use flatbuffers::Follow; - // Safety: - // Created from a valid Table for this object - // Which contains a valid flatbuffer in this slot - unsafe { >>::follow(data.bytes(), 0) } - }) - } - #[inline] - pub fn claim_v1(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - ChannelInstruction::VT_CLAIM_V1, - None, - ) - } - } - pub fn claim_v1_nested_flatbuffer(&'a self) -> Option> { - self.claim_v1().map(|data| { - use flatbuffers::Follow; - // Safety: - // Created from a valid Table for this object - // Which contains a valid flatbuffer in this slot - unsafe { >>::follow(data.bytes(), 0) } - }) - } - #[inline] - pub fn input_set_v1(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - ChannelInstruction::VT_INPUT_SET_V1, - None, - ) - } - } - pub fn input_set_v1_nested_flatbuffer(&'a self) -> Option> { - self.input_set_v1().map(|data| { - use flatbuffers::Follow; - // Safety: - // Created from a valid Table for this object - // Which contains a valid flatbuffer in this slot - unsafe { >>::follow(data.bytes(), 0) } - }) - } -} - -impl flatbuffers::Verifiable for ChannelInstruction<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("ix_type", Self::VT_IX_TYPE, false)? - .visit_field::>>( - "execute_v1", - Self::VT_EXECUTE_V1, - false, - )? - .visit_field::>>( - "status_v1", - Self::VT_STATUS_V1, - false, - )? - .visit_field::>>( - "deploy_v1", - Self::VT_DEPLOY_V1, - false, - )? - .visit_field::>>( - "claim_v1", - Self::VT_CLAIM_V1, - false, - )? - .visit_field::>>( - "input_set_v1", - Self::VT_INPUT_SET_V1, - false, - )? - .finish(); - Ok(()) - } -} -pub struct ChannelInstructionArgs<'a> { - pub ix_type: ChannelInstructionIxType, - pub execute_v1: Option>>, - pub status_v1: Option>>, - pub deploy_v1: Option>>, - pub claim_v1: Option>>, - pub input_set_v1: Option>>, -} -impl<'a> Default for ChannelInstructionArgs<'a> { - #[inline] - fn default() -> Self { - ChannelInstructionArgs { - ix_type: ChannelInstructionIxType::ExecuteV1, - execute_v1: None, - status_v1: None, - deploy_v1: None, - claim_v1: None, - input_set_v1: None, - } - } -} - -pub struct ChannelInstructionBuilder<'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> ChannelInstructionBuilder<'a, 'b, A> { - #[inline] - pub fn add_ix_type(&mut self, ix_type: ChannelInstructionIxType) { - self.fbb_.push_slot::( - ChannelInstruction::VT_IX_TYPE, - ix_type, - ChannelInstructionIxType::ExecuteV1, - ); - } - #[inline] - pub fn add_execute_v1( - &mut self, - execute_v1: flatbuffers::WIPOffset>, - ) { - self.fbb_.push_slot_always::>( - ChannelInstruction::VT_EXECUTE_V1, - execute_v1, - ); - } - #[inline] - pub fn add_status_v1( - &mut self, - status_v1: flatbuffers::WIPOffset>, - ) { - self.fbb_.push_slot_always::>( - ChannelInstruction::VT_STATUS_V1, - status_v1, - ); - } - #[inline] - pub fn add_deploy_v1( - &mut self, - deploy_v1: flatbuffers::WIPOffset>, - ) { - self.fbb_.push_slot_always::>( - ChannelInstruction::VT_DEPLOY_V1, - deploy_v1, - ); - } - #[inline] - pub fn add_claim_v1(&mut self, claim_v1: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>( - ChannelInstruction::VT_CLAIM_V1, - claim_v1, - ); - } - #[inline] - pub fn add_input_set_v1( - &mut self, - input_set_v1: flatbuffers::WIPOffset>, - ) { - self.fbb_.push_slot_always::>( - ChannelInstruction::VT_INPUT_SET_V1, - input_set_v1, - ); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> ChannelInstructionBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - ChannelInstructionBuilder { - 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 ChannelInstruction<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("ChannelInstruction"); - ds.field("ix_type", &self.ix_type()); - ds.field("execute_v1", &self.execute_v1()); - ds.field("status_v1", &self.status_v1()); - ds.field("deploy_v1", &self.deploy_v1()); - ds.field("claim_v1", &self.claim_v1()); - ds.field("input_set_v1", &self.input_set_v1()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct ChannelInstructionT { - pub ix_type: ChannelInstructionIxType, - pub execute_v1: Option>, - pub status_v1: Option>, - pub deploy_v1: Option>, - pub claim_v1: Option>, - pub input_set_v1: Option>, -} -impl Default for ChannelInstructionT { - fn default() -> Self { - Self { - ix_type: ChannelInstructionIxType::ExecuteV1, - execute_v1: None, - status_v1: None, - deploy_v1: None, - claim_v1: None, - input_set_v1: None, - } - } -} -impl ChannelInstructionT { - pub fn pack<'b, A: flatbuffers::Allocator + 'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>, - ) -> flatbuffers::WIPOffset> { - let ix_type = self.ix_type; - let execute_v1 = self.execute_v1.as_ref().map(|x| _fbb.create_vector(x)); - let status_v1 = self.status_v1.as_ref().map(|x| _fbb.create_vector(x)); - let deploy_v1 = self.deploy_v1.as_ref().map(|x| _fbb.create_vector(x)); - let claim_v1 = self.claim_v1.as_ref().map(|x| _fbb.create_vector(x)); - let input_set_v1 = self.input_set_v1.as_ref().map(|x| _fbb.create_vector(x)); - ChannelInstruction::create( - _fbb, - &ChannelInstructionArgs { - ix_type, - execute_v1, - status_v1, - deploy_v1, - claim_v1, - input_set_v1, - }, - ) - } -} -#[inline] -/// Verifies that a buffer of bytes contains a `ChannelInstruction` -/// 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_channel_instruction_unchecked`. -pub fn root_as_channel_instruction( - buf: &[u8], -) -> Result { - flatbuffers::root::(buf) -} -#[inline] -/// Verifies that a buffer of bytes contains a size prefixed -/// `ChannelInstruction` 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_channel_instruction_unchecked`. -pub fn size_prefixed_root_as_channel_instruction( - buf: &[u8], -) -> Result { - flatbuffers::size_prefixed_root::(buf) -} -#[inline] -/// Verifies, with the given options, that a buffer of bytes -/// contains a `ChannelInstruction` 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_channel_instruction_unchecked`. -pub fn root_as_channel_instruction_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 `ChannelInstruction` 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_channel_instruction_unchecked`. -pub fn size_prefixed_root_as_channel_instruction_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 ChannelInstruction and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid `ChannelInstruction`. -pub unsafe fn root_as_channel_instruction_unchecked(buf: &[u8]) -> ChannelInstruction { - flatbuffers::root_unchecked::(buf) -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a size prefixed ChannelInstruction and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid size prefixed `ChannelInstruction`. -pub unsafe fn size_prefixed_root_as_channel_instruction_unchecked( - buf: &[u8], -) -> ChannelInstruction { - flatbuffers::size_prefixed_root_unchecked::(buf) -} -#[inline] -pub fn finish_channel_instruction_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_channel_instruction_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, None); -} diff --git a/schemas-rust/src/claim_v1_generated.rs b/schemas-rust/src/claim_v1_generated.rs deleted file mode 100644 index d3d0400..0000000 --- a/schemas-rust/src/claim_v1_generated.rs +++ /dev/null @@ -1,257 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -// @generated - -use core::cmp::Ordering; -use core::mem; - -extern crate flatbuffers; -use self::flatbuffers::{EndianScalar, Follow}; - -pub enum ClaimV1Offset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct ClaimV1<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for ClaimV1<'a> { - type Inner = ClaimV1<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } -} - -impl<'a> ClaimV1<'a> { - pub const VT_EXECUTION_ID: flatbuffers::VOffsetT = 4; - pub const VT_BLOCK_COMMITMENT: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - ClaimV1 { _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 ClaimV1Args<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = ClaimV1Builder::new(_fbb); - builder.add_block_commitment(args.block_commitment); - if let Some(x) = args.execution_id { - builder.add_execution_id(x); - } - builder.finish() - } - - pub fn unpack(&self) -> ClaimV1T { - let execution_id = self.execution_id().map(|x| x.to_string()); - let block_commitment = self.block_commitment(); - ClaimV1T { - execution_id, - block_commitment, - } - } - - #[inline] - pub fn execution_id(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(ClaimV1::VT_EXECUTION_ID, None) - } - } - #[inline] - pub fn block_commitment(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(ClaimV1::VT_BLOCK_COMMITMENT, Some(0)) - .unwrap() - } - } -} - -impl flatbuffers::Verifiable for ClaimV1<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>( - "execution_id", - Self::VT_EXECUTION_ID, - false, - )? - .visit_field::("block_commitment", Self::VT_BLOCK_COMMITMENT, false)? - .finish(); - Ok(()) - } -} -pub struct ClaimV1Args<'a> { - pub execution_id: Option>, - pub block_commitment: u64, -} -impl<'a> Default for ClaimV1Args<'a> { - #[inline] - fn default() -> Self { - ClaimV1Args { - execution_id: None, - block_commitment: 0, - } - } -} - -pub struct ClaimV1Builder<'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> ClaimV1Builder<'a, 'b, A> { - #[inline] - pub fn add_execution_id(&mut self, execution_id: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(ClaimV1::VT_EXECUTION_ID, execution_id); - } - #[inline] - pub fn add_block_commitment(&mut self, block_commitment: u64) { - self.fbb_ - .push_slot::(ClaimV1::VT_BLOCK_COMMITMENT, block_commitment, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ClaimV1Builder<'a, 'b, A> { - let start = _fbb.start_table(); - ClaimV1Builder { - 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 ClaimV1<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("ClaimV1"); - ds.field("execution_id", &self.execution_id()); - ds.field("block_commitment", &self.block_commitment()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct ClaimV1T { - pub execution_id: Option, - pub block_commitment: u64, -} -impl Default for ClaimV1T { - fn default() -> Self { - Self { - execution_id: None, - block_commitment: 0, - } - } -} -impl ClaimV1T { - pub fn pack<'b, A: flatbuffers::Allocator + 'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>, - ) -> flatbuffers::WIPOffset> { - let execution_id = self.execution_id.as_ref().map(|x| _fbb.create_string(x)); - let block_commitment = self.block_commitment; - ClaimV1::create( - _fbb, - &ClaimV1Args { - execution_id, - block_commitment, - }, - ) - } -} -#[inline] -/// Verifies that a buffer of bytes contains a `ClaimV1` -/// 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_claim_v1_unchecked`. -pub fn root_as_claim_v1(buf: &[u8]) -> Result { - flatbuffers::root::(buf) -} -#[inline] -/// Verifies that a buffer of bytes contains a size prefixed -/// `ClaimV1` 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_claim_v1_unchecked`. -pub fn size_prefixed_root_as_claim_v1( - buf: &[u8], -) -> Result { - flatbuffers::size_prefixed_root::(buf) -} -#[inline] -/// Verifies, with the given options, that a buffer of bytes -/// contains a `ClaimV1` 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_claim_v1_unchecked`. -pub fn root_as_claim_v1_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 `ClaimV1` 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_claim_v1_unchecked`. -pub fn size_prefixed_root_as_claim_v1_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 ClaimV1 and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid `ClaimV1`. -pub unsafe fn root_as_claim_v1_unchecked(buf: &[u8]) -> ClaimV1 { - flatbuffers::root_unchecked::(buf) -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a size prefixed ClaimV1 and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid size prefixed `ClaimV1`. -pub unsafe fn size_prefixed_root_as_claim_v1_unchecked(buf: &[u8]) -> ClaimV1 { - flatbuffers::size_prefixed_root_unchecked::(buf) -} -#[inline] -pub fn finish_claim_v1_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_claim_v1_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, None); -} diff --git a/schemas-rust/src/deploy_v1_generated.rs b/schemas-rust/src/deploy_v1_generated.rs deleted file mode 100644 index 8b533eb..0000000 --- a/schemas-rust/src/deploy_v1_generated.rs +++ /dev/null @@ -1,390 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -// @generated - -use crate::input_type_generated::*; -use core::cmp::Ordering; -use core::mem; - -extern crate flatbuffers; -use self::flatbuffers::{EndianScalar, Follow}; - -pub enum DeployV1Offset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct DeployV1<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for DeployV1<'a> { - type Inner = DeployV1<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } -} - -impl<'a> DeployV1<'a> { - pub const VT_OWNER: flatbuffers::VOffsetT = 4; - pub const VT_IMAGE_ID: flatbuffers::VOffsetT = 6; - pub const VT_PROGRAM_NAME: flatbuffers::VOffsetT = 8; - pub const VT_URL: flatbuffers::VOffsetT = 10; - pub const VT_SIZE_: flatbuffers::VOffsetT = 12; - pub const VT_INPUTS: flatbuffers::VOffsetT = 14; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - DeployV1 { _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 DeployV1Args<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = DeployV1Builder::new(_fbb); - builder.add_size_(args.size_); - if let Some(x) = args.inputs { - builder.add_inputs(x); - } - if let Some(x) = args.url { - builder.add_url(x); - } - if let Some(x) = args.program_name { - builder.add_program_name(x); - } - if let Some(x) = args.image_id { - builder.add_image_id(x); - } - if let Some(x) = args.owner { - builder.add_owner(x); - } - builder.finish() - } - - pub fn unpack(&self) -> DeployV1T { - let owner = self.owner().map(|x| x.into_iter().collect()); - let image_id = self.image_id().map(|x| x.to_string()); - let program_name = self.program_name().map(|x| x.to_string()); - let url = self.url().map(|x| x.to_string()); - let size_ = self.size_(); - let inputs = self.inputs().map(|x| x.into_iter().collect()); - DeployV1T { - owner, - image_id, - program_name, - url, - size_, - inputs, - } - } - - #[inline] - pub fn owner(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - DeployV1::VT_OWNER, - None, - ) - } - } - #[inline] - pub fn image_id(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(DeployV1::VT_IMAGE_ID, None) - } - } - #[inline] - pub fn program_name(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(DeployV1::VT_PROGRAM_NAME, None) - } - } - #[inline] - pub fn url(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(DeployV1::VT_URL, None) - } - } - #[inline] - pub fn size_(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(DeployV1::VT_SIZE_, Some(0)).unwrap() } - } - #[inline] - pub fn inputs(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - DeployV1::VT_INPUTS, - None, - ) - } - } -} - -impl flatbuffers::Verifiable for DeployV1<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>>( - "owner", - Self::VT_OWNER, - false, - )? - .visit_field::>( - "image_id", - Self::VT_IMAGE_ID, - false, - )? - .visit_field::>( - "program_name", - Self::VT_PROGRAM_NAME, - false, - )? - .visit_field::>("url", Self::VT_URL, false)? - .visit_field::("size_", Self::VT_SIZE_, false)? - .visit_field::>>( - "inputs", - Self::VT_INPUTS, - false, - )? - .finish(); - Ok(()) - } -} -pub struct DeployV1Args<'a> { - pub owner: Option>>, - pub image_id: Option>, - pub program_name: Option>, - pub url: Option>, - pub size_: u64, - pub inputs: Option>>, -} -impl<'a> Default for DeployV1Args<'a> { - #[inline] - fn default() -> Self { - DeployV1Args { - owner: None, - image_id: None, - program_name: None, - url: None, - size_: 0, - inputs: None, - } - } -} - -pub struct DeployV1Builder<'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> DeployV1Builder<'a, 'b, A> { - #[inline] - pub fn add_owner(&mut self, owner: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>(DeployV1::VT_OWNER, owner); - } - #[inline] - pub fn add_image_id(&mut self, image_id: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(DeployV1::VT_IMAGE_ID, image_id); - } - #[inline] - pub fn add_program_name(&mut self, program_name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(DeployV1::VT_PROGRAM_NAME, program_name); - } - #[inline] - pub fn add_url(&mut self, url: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(DeployV1::VT_URL, url); - } - #[inline] - pub fn add_size_(&mut self, size_: u64) { - self.fbb_.push_slot::(DeployV1::VT_SIZE_, size_, 0); - } - #[inline] - pub fn add_inputs( - &mut self, - inputs: flatbuffers::WIPOffset>, - ) { - self.fbb_ - .push_slot_always::>(DeployV1::VT_INPUTS, inputs); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> DeployV1Builder<'a, 'b, A> { - let start = _fbb.start_table(); - DeployV1Builder { - 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 DeployV1<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("DeployV1"); - ds.field("owner", &self.owner()); - ds.field("image_id", &self.image_id()); - ds.field("program_name", &self.program_name()); - ds.field("url", &self.url()); - ds.field("size_", &self.size_()); - ds.field("inputs", &self.inputs()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct DeployV1T { - pub owner: Option>, - pub image_id: Option, - pub program_name: Option, - pub url: Option, - pub size_: u64, - pub inputs: Option>, -} -impl Default for DeployV1T { - fn default() -> Self { - Self { - owner: None, - image_id: None, - program_name: None, - url: None, - size_: 0, - inputs: None, - } - } -} -impl DeployV1T { - pub fn pack<'b, A: flatbuffers::Allocator + 'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>, - ) -> flatbuffers::WIPOffset> { - let owner = self.owner.as_ref().map(|x| _fbb.create_vector(x)); - let image_id = self.image_id.as_ref().map(|x| _fbb.create_string(x)); - let program_name = self.program_name.as_ref().map(|x| _fbb.create_string(x)); - let url = self.url.as_ref().map(|x| _fbb.create_string(x)); - let size_ = self.size_; - let inputs = self.inputs.as_ref().map(|x| _fbb.create_vector(x)); - DeployV1::create( - _fbb, - &DeployV1Args { - owner, - image_id, - program_name, - url, - size_, - inputs, - }, - ) - } -} -#[inline] -/// Verifies that a buffer of bytes contains a `DeployV1` -/// 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_deploy_v1_unchecked`. -pub fn root_as_deploy_v1(buf: &[u8]) -> Result { - flatbuffers::root::(buf) -} -#[inline] -/// Verifies that a buffer of bytes contains a size prefixed -/// `DeployV1` 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_deploy_v1_unchecked`. -pub fn size_prefixed_root_as_deploy_v1( - buf: &[u8], -) -> Result { - flatbuffers::size_prefixed_root::(buf) -} -#[inline] -/// Verifies, with the given options, that a buffer of bytes -/// contains a `DeployV1` 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_deploy_v1_unchecked`. -pub fn root_as_deploy_v1_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 `DeployV1` 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_deploy_v1_unchecked`. -pub fn size_prefixed_root_as_deploy_v1_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 DeployV1 and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid `DeployV1`. -pub unsafe fn root_as_deploy_v1_unchecked(buf: &[u8]) -> DeployV1 { - flatbuffers::root_unchecked::(buf) -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a size prefixed DeployV1 and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid size prefixed `DeployV1`. -pub unsafe fn size_prefixed_root_as_deploy_v1_unchecked(buf: &[u8]) -> DeployV1 { - flatbuffers::size_prefixed_root_unchecked::(buf) -} -#[inline] -pub fn finish_deploy_v1_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_deploy_v1_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, None); -} diff --git a/schemas-rust/src/execution_request_v1_generated.rs b/schemas-rust/src/execution_request_v1_generated.rs deleted file mode 100644 index ad42974..0000000 --- a/schemas-rust/src/execution_request_v1_generated.rs +++ /dev/null @@ -1,738 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -// @generated - -use crate::input_type_generated::*; -use core::cmp::Ordering; -use core::mem; - -extern crate flatbuffers; -use self::flatbuffers::{EndianScalar, Follow}; - -// struct Account, aligned to 8 -#[repr(transparent)] -#[derive(Clone, Copy, PartialEq)] -pub struct Account(pub [u8; 40]); -impl Default for Account { - fn default() -> Self { - Self([0; 40]) - } -} -impl core::fmt::Debug for Account { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - f.debug_struct("Account") - .field("writable", &self.writable()) - .field("pubkey", &self.pubkey()) - .finish() - } -} - -impl flatbuffers::SimpleToVerifyInSlice for Account {} -impl<'a> flatbuffers::Follow<'a> for Account { - type Inner = &'a Account; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - <&'a Account>::follow(buf, loc) - } -} -impl<'a> flatbuffers::Follow<'a> for &'a Account { - type Inner = &'a Account; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) - } -} -impl<'b> flatbuffers::Push for Account { - type Output = Account; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const Account as *const u8, Self::size()); - dst.copy_from_slice(src); - } -} - -impl<'a> flatbuffers::Verifiable for Account { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.in_buffer::(pos) - } -} - -impl<'a> Account { - #[allow(clippy::too_many_arguments)] - pub fn new(writable: u8, pubkey: &[u8; 32]) -> Self { - let mut s = Self([0; 40]); - s.set_writable(writable); - s.set_pubkey(pubkey); - s - } - - pub fn writable(&self) -> u8 { - 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_writable(&mut self, x: u8) { - 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 pubkey(&'a self) -> flatbuffers::Array<'a, u8, 32> { - // Safety: - // Created from a valid Table for this object - // Which contains a valid array in this slot - unsafe { flatbuffers::Array::follow(&self.0, 1) } - } - - pub fn set_pubkey(&mut self, items: &[u8; 32]) { - // Safety: - // Created from a valid Table for this object - // Which contains a valid array in this slot - unsafe { flatbuffers::emplace_scalar_array(&mut self.0, 1, items) }; - } - - pub fn unpack(&self) -> AccountT { - AccountT { - writable: self.writable(), - pubkey: self.pubkey().into(), - } - } -} - -#[derive(Debug, Clone, PartialEq, Default)] -pub struct AccountT { - pub writable: u8, - pub pubkey: [u8; 32], -} -impl AccountT { - pub fn pack(&self) -> Account { - Account::new(self.writable, &self.pubkey) - } -} - -pub enum ExecutionRequestV1Offset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct ExecutionRequestV1<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for ExecutionRequestV1<'a> { - type Inner = ExecutionRequestV1<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } -} - -impl<'a> ExecutionRequestV1<'a> { - pub const VT_TIP: flatbuffers::VOffsetT = 4; - pub const VT_EXECUTION_ID: flatbuffers::VOffsetT = 6; - pub const VT_IMAGE_ID: flatbuffers::VOffsetT = 8; - pub const VT_CALLBACK_PROGRAM_ID: flatbuffers::VOffsetT = 10; - pub const VT_CALLBACK_INSTRUCTION_PREFIX: flatbuffers::VOffsetT = 12; - pub const VT_FORWARD_OUTPUT: flatbuffers::VOffsetT = 14; - pub const VT_VERIFY_INPUT_HASH: flatbuffers::VOffsetT = 16; - pub const VT_INPUT: flatbuffers::VOffsetT = 18; - pub const VT_INPUT_DIGEST: flatbuffers::VOffsetT = 20; - pub const VT_MAX_BLOCK_HEIGHT: flatbuffers::VOffsetT = 22; - pub const VT_CALLBACK_EXTRA_ACCOUNTS: flatbuffers::VOffsetT = 24; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - ExecutionRequestV1 { _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 ExecutionRequestV1Args<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = ExecutionRequestV1Builder::new(_fbb); - builder.add_max_block_height(args.max_block_height); - builder.add_tip(args.tip); - if let Some(x) = args.callback_extra_accounts { - builder.add_callback_extra_accounts(x); - } - if let Some(x) = args.input_digest { - builder.add_input_digest(x); - } - if let Some(x) = args.input { - builder.add_input(x); - } - if let Some(x) = args.callback_instruction_prefix { - builder.add_callback_instruction_prefix(x); - } - if let Some(x) = args.callback_program_id { - builder.add_callback_program_id(x); - } - if let Some(x) = args.image_id { - builder.add_image_id(x); - } - if let Some(x) = args.execution_id { - builder.add_execution_id(x); - } - builder.add_verify_input_hash(args.verify_input_hash); - builder.add_forward_output(args.forward_output); - builder.finish() - } - - pub fn unpack(&self) -> ExecutionRequestV1T { - let tip = self.tip(); - let execution_id = self.execution_id().map(|x| x.to_string()); - let image_id = self.image_id().map(|x| x.to_string()); - let callback_program_id = self.callback_program_id().map(|x| x.into_iter().collect()); - let callback_instruction_prefix = self - .callback_instruction_prefix() - .map(|x| x.into_iter().collect()); - let forward_output = self.forward_output(); - let verify_input_hash = self.verify_input_hash(); - let input = self.input().map(|x| x.iter().map(|t| t.unpack()).collect()); - let input_digest = self.input_digest().map(|x| x.into_iter().collect()); - let max_block_height = self.max_block_height(); - let callback_extra_accounts = self - .callback_extra_accounts() - .map(|x| x.iter().map(|t| t.unpack()).collect()); - ExecutionRequestV1T { - tip, - execution_id, - image_id, - callback_program_id, - callback_instruction_prefix, - forward_output, - verify_input_hash, - input, - input_digest, - max_block_height, - callback_extra_accounts, - } - } - - #[inline] - pub fn tip(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(ExecutionRequestV1::VT_TIP, Some(0)) - .unwrap() - } - } - #[inline] - pub fn execution_id(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>( - ExecutionRequestV1::VT_EXECUTION_ID, - None, - ) - } - } - #[inline] - pub fn image_id(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(ExecutionRequestV1::VT_IMAGE_ID, None) - } - } - #[inline] - pub fn callback_program_id(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - ExecutionRequestV1::VT_CALLBACK_PROGRAM_ID, - None, - ) - } - } - #[inline] - pub fn callback_instruction_prefix(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - ExecutionRequestV1::VT_CALLBACK_INSTRUCTION_PREFIX, - None, - ) - } - } - #[inline] - pub fn forward_output(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(ExecutionRequestV1::VT_FORWARD_OUTPUT, Some(false)) - .unwrap() - } - } - #[inline] - pub fn verify_input_hash(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(ExecutionRequestV1::VT_VERIFY_INPUT_HASH, Some(true)) - .unwrap() - } - } - #[inline] - pub fn input( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(ExecutionRequestV1::VT_INPUT, None) - } - } - #[inline] - pub fn input_digest(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - ExecutionRequestV1::VT_INPUT_DIGEST, - None, - ) - } - } - #[inline] - pub fn max_block_height(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(ExecutionRequestV1::VT_MAX_BLOCK_HEIGHT, Some(0)) - .unwrap() - } - } - #[inline] - pub fn callback_extra_accounts(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - ExecutionRequestV1::VT_CALLBACK_EXTRA_ACCOUNTS, - None, - ) - } - } -} - -impl flatbuffers::Verifiable for ExecutionRequestV1<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("tip", Self::VT_TIP, false)? - .visit_field::>( - "execution_id", - Self::VT_EXECUTION_ID, - false, - )? - .visit_field::>( - "image_id", - Self::VT_IMAGE_ID, - false, - )? - .visit_field::>>( - "callback_program_id", - Self::VT_CALLBACK_PROGRAM_ID, - false, - )? - .visit_field::>>( - "callback_instruction_prefix", - Self::VT_CALLBACK_INSTRUCTION_PREFIX, - false, - )? - .visit_field::("forward_output", Self::VT_FORWARD_OUTPUT, false)? - .visit_field::("verify_input_hash", Self::VT_VERIFY_INPUT_HASH, false)? - .visit_field::>, - >>("input", Self::VT_INPUT, false)? - .visit_field::>>( - "input_digest", - Self::VT_INPUT_DIGEST, - false, - )? - .visit_field::("max_block_height", Self::VT_MAX_BLOCK_HEIGHT, false)? - .visit_field::>>( - "callback_extra_accounts", - Self::VT_CALLBACK_EXTRA_ACCOUNTS, - false, - )? - .finish(); - Ok(()) - } -} -pub struct ExecutionRequestV1Args<'a> { - pub tip: u64, - pub execution_id: Option>, - pub image_id: Option>, - pub callback_program_id: Option>>, - pub callback_instruction_prefix: Option>>, - pub forward_output: bool, - pub verify_input_hash: bool, - pub input: Option< - flatbuffers::WIPOffset>>>, - >, - pub input_digest: Option>>, - pub max_block_height: u64, - pub callback_extra_accounts: Option>>, -} -impl<'a> Default for ExecutionRequestV1Args<'a> { - #[inline] - fn default() -> Self { - ExecutionRequestV1Args { - tip: 0, - execution_id: None, - image_id: None, - callback_program_id: None, - callback_instruction_prefix: None, - forward_output: false, - verify_input_hash: true, - input: None, - input_digest: None, - max_block_height: 0, - callback_extra_accounts: None, - } - } -} - -pub struct ExecutionRequestV1Builder<'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> ExecutionRequestV1Builder<'a, 'b, A> { - #[inline] - pub fn add_tip(&mut self, tip: u64) { - self.fbb_ - .push_slot::(ExecutionRequestV1::VT_TIP, tip, 0); - } - #[inline] - pub fn add_execution_id(&mut self, execution_id: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>( - ExecutionRequestV1::VT_EXECUTION_ID, - execution_id, - ); - } - #[inline] - pub fn add_image_id(&mut self, image_id: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>( - ExecutionRequestV1::VT_IMAGE_ID, - image_id, - ); - } - #[inline] - pub fn add_callback_program_id( - &mut self, - callback_program_id: flatbuffers::WIPOffset>, - ) { - self.fbb_.push_slot_always::>( - ExecutionRequestV1::VT_CALLBACK_PROGRAM_ID, - callback_program_id, - ); - } - #[inline] - pub fn add_callback_instruction_prefix( - &mut self, - callback_instruction_prefix: flatbuffers::WIPOffset>, - ) { - self.fbb_.push_slot_always::>( - ExecutionRequestV1::VT_CALLBACK_INSTRUCTION_PREFIX, - callback_instruction_prefix, - ); - } - #[inline] - pub fn add_forward_output(&mut self, forward_output: bool) { - self.fbb_ - .push_slot::(ExecutionRequestV1::VT_FORWARD_OUTPUT, forward_output, false); - } - #[inline] - pub fn add_verify_input_hash(&mut self, verify_input_hash: bool) { - self.fbb_.push_slot::( - ExecutionRequestV1::VT_VERIFY_INPUT_HASH, - verify_input_hash, - true, - ); - } - #[inline] - pub fn add_input( - &mut self, - input: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(ExecutionRequestV1::VT_INPUT, input); - } - #[inline] - pub fn add_input_digest( - &mut self, - input_digest: flatbuffers::WIPOffset>, - ) { - self.fbb_.push_slot_always::>( - ExecutionRequestV1::VT_INPUT_DIGEST, - input_digest, - ); - } - #[inline] - pub fn add_max_block_height(&mut self, max_block_height: u64) { - self.fbb_ - .push_slot::(ExecutionRequestV1::VT_MAX_BLOCK_HEIGHT, max_block_height, 0); - } - #[inline] - pub fn add_callback_extra_accounts( - &mut self, - callback_extra_accounts: flatbuffers::WIPOffset>, - ) { - self.fbb_.push_slot_always::>( - ExecutionRequestV1::VT_CALLBACK_EXTRA_ACCOUNTS, - callback_extra_accounts, - ); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> ExecutionRequestV1Builder<'a, 'b, A> { - let start = _fbb.start_table(); - ExecutionRequestV1Builder { - 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 ExecutionRequestV1<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("ExecutionRequestV1"); - ds.field("tip", &self.tip()); - ds.field("execution_id", &self.execution_id()); - ds.field("image_id", &self.image_id()); - ds.field("callback_program_id", &self.callback_program_id()); - ds.field( - "callback_instruction_prefix", - &self.callback_instruction_prefix(), - ); - ds.field("forward_output", &self.forward_output()); - ds.field("verify_input_hash", &self.verify_input_hash()); - ds.field("input", &self.input()); - ds.field("input_digest", &self.input_digest()); - ds.field("max_block_height", &self.max_block_height()); - ds.field("callback_extra_accounts", &self.callback_extra_accounts()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct ExecutionRequestV1T { - pub tip: u64, - pub execution_id: Option, - pub image_id: Option, - pub callback_program_id: Option>, - pub callback_instruction_prefix: Option>, - pub forward_output: bool, - pub verify_input_hash: bool, - pub input: Option>, - pub input_digest: Option>, - pub max_block_height: u64, - pub callback_extra_accounts: Option>, -} -impl Default for ExecutionRequestV1T { - fn default() -> Self { - Self { - tip: 0, - execution_id: None, - image_id: None, - callback_program_id: None, - callback_instruction_prefix: None, - forward_output: false, - verify_input_hash: true, - input: None, - input_digest: None, - max_block_height: 0, - callback_extra_accounts: None, - } - } -} -impl ExecutionRequestV1T { - pub fn pack<'b, A: flatbuffers::Allocator + 'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>, - ) -> flatbuffers::WIPOffset> { - let tip = self.tip; - let execution_id = self.execution_id.as_ref().map(|x| _fbb.create_string(x)); - let image_id = self.image_id.as_ref().map(|x| _fbb.create_string(x)); - let callback_program_id = self - .callback_program_id - .as_ref() - .map(|x| _fbb.create_vector(x)); - let callback_instruction_prefix = self - .callback_instruction_prefix - .as_ref() - .map(|x| _fbb.create_vector(x)); - let forward_output = self.forward_output; - let verify_input_hash = self.verify_input_hash; - let input = self.input.as_ref().map(|x| { - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect(); - _fbb.create_vector(&w) - }); - let input_digest = self.input_digest.as_ref().map(|x| _fbb.create_vector(x)); - let max_block_height = self.max_block_height; - let callback_extra_accounts = self.callback_extra_accounts.as_ref().map(|x| { - let w: Vec<_> = x.iter().map(|t| t.pack()).collect(); - _fbb.create_vector(&w) - }); - ExecutionRequestV1::create( - _fbb, - &ExecutionRequestV1Args { - tip, - execution_id, - image_id, - callback_program_id, - callback_instruction_prefix, - forward_output, - verify_input_hash, - input, - input_digest, - max_block_height, - callback_extra_accounts, - }, - ) - } -} -#[inline] -/// Verifies that a buffer of bytes contains a `ExecutionRequestV1` -/// 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_execution_request_v1_unchecked`. -pub fn root_as_execution_request_v1( - buf: &[u8], -) -> Result { - flatbuffers::root::(buf) -} -#[inline] -/// Verifies that a buffer of bytes contains a size prefixed -/// `ExecutionRequestV1` 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_execution_request_v1_unchecked`. -pub fn size_prefixed_root_as_execution_request_v1( - buf: &[u8], -) -> Result { - flatbuffers::size_prefixed_root::(buf) -} -#[inline] -/// Verifies, with the given options, that a buffer of bytes -/// contains a `ExecutionRequestV1` 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_execution_request_v1_unchecked`. -pub fn root_as_execution_request_v1_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 `ExecutionRequestV1` 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_execution_request_v1_unchecked`. -pub fn size_prefixed_root_as_execution_request_v1_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 ExecutionRequestV1 and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid `ExecutionRequestV1`. -pub unsafe fn root_as_execution_request_v1_unchecked(buf: &[u8]) -> ExecutionRequestV1 { - flatbuffers::root_unchecked::(buf) -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a size prefixed ExecutionRequestV1 and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid size prefixed `ExecutionRequestV1`. -pub unsafe fn size_prefixed_root_as_execution_request_v1_unchecked( - buf: &[u8], -) -> ExecutionRequestV1 { - flatbuffers::size_prefixed_root_unchecked::(buf) -} -#[inline] -pub fn finish_execution_request_v1_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_execution_request_v1_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, None); -} diff --git a/schemas-rust/src/input_set_generated.rs b/schemas-rust/src/input_set_generated.rs deleted file mode 100644 index f09c6a8..0000000 --- a/schemas-rust/src/input_set_generated.rs +++ /dev/null @@ -1,232 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -// @generated - -use crate::input_type_generated::*; -use core::cmp::Ordering; -use core::mem; - -extern crate flatbuffers; -use self::flatbuffers::{EndianScalar, Follow}; - -pub enum InputSetOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct InputSet<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for InputSet<'a> { - type Inner = InputSet<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } -} - -impl<'a> InputSet<'a> { - pub const VT_INPUTS: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - InputSet { _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 InputSetArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = InputSetBuilder::new(_fbb); - if let Some(x) = args.inputs { - builder.add_inputs(x); - } - builder.finish() - } - - pub fn unpack(&self) -> InputSetT { - let inputs = self - .inputs() - .map(|x| x.iter().map(|t| t.unpack()).collect()); - InputSetT { inputs } - } - - #[inline] - pub fn inputs( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(InputSet::VT_INPUTS, None) - } - } -} - -impl flatbuffers::Verifiable for InputSet<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>, - >>("inputs", Self::VT_INPUTS, false)? - .finish(); - Ok(()) - } -} -pub struct InputSetArgs<'a> { - pub inputs: Option< - flatbuffers::WIPOffset>>>, - >, -} -impl<'a> Default for InputSetArgs<'a> { - #[inline] - fn default() -> Self { - InputSetArgs { inputs: None } - } -} - -pub struct InputSetBuilder<'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> InputSetBuilder<'a, 'b, A> { - #[inline] - pub fn add_inputs( - &mut self, - inputs: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(InputSet::VT_INPUTS, inputs); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> InputSetBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - InputSetBuilder { - 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 InputSet<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("InputSet"); - ds.field("inputs", &self.inputs()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct InputSetT { - pub inputs: Option>, -} -impl Default for InputSetT { - fn default() -> Self { - Self { inputs: None } - } -} -impl InputSetT { - pub fn pack<'b, A: flatbuffers::Allocator + 'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>, - ) -> flatbuffers::WIPOffset> { - let inputs = self.inputs.as_ref().map(|x| { - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect(); - _fbb.create_vector(&w) - }); - InputSet::create(_fbb, &InputSetArgs { inputs }) - } -} -#[inline] -/// Verifies that a buffer of bytes contains a `InputSet` -/// 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_input_set_unchecked`. -pub fn root_as_input_set(buf: &[u8]) -> Result { - flatbuffers::root::(buf) -} -#[inline] -/// Verifies that a buffer of bytes contains a size prefixed -/// `InputSet` 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_input_set_unchecked`. -pub fn size_prefixed_root_as_input_set( - buf: &[u8], -) -> Result { - flatbuffers::size_prefixed_root::(buf) -} -#[inline] -/// Verifies, with the given options, that a buffer of bytes -/// contains a `InputSet` 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_input_set_unchecked`. -pub fn root_as_input_set_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 `InputSet` 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_input_set_unchecked`. -pub fn size_prefixed_root_as_input_set_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 InputSet and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid `InputSet`. -pub unsafe fn root_as_input_set_unchecked(buf: &[u8]) -> InputSet { - flatbuffers::root_unchecked::(buf) -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a size prefixed InputSet and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid size prefixed `InputSet`. -pub unsafe fn size_prefixed_root_as_input_set_unchecked(buf: &[u8]) -> InputSet { - flatbuffers::size_prefixed_root_unchecked::(buf) -} -#[inline] -pub fn finish_input_set_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_input_set_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, None); -} diff --git a/schemas-rust/src/input_set_op_v1_generated.rs b/schemas-rust/src/input_set_op_v1_generated.rs deleted file mode 100644 index 25cb445..0000000 --- a/schemas-rust/src/input_set_op_v1_generated.rs +++ /dev/null @@ -1,383 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -// @generated - -use crate::input_type_generated::*; -use core::cmp::Ordering; -use core::mem; - -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." -)] -pub const ENUM_MIN_INPUT_SET_OP: u8 = 0; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MAX_INPUT_SET_OP: 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_INPUT_SET_OP: [InputSetOp; 3] = - [InputSetOp::Create, InputSetOp::Update, InputSetOp::Delete]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct InputSetOp(pub u8); -#[allow(non_upper_case_globals)] -impl InputSetOp { - pub const Create: Self = Self(0); - pub const Update: Self = Self(1); - pub const Delete: Self = Self(2); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 2; - pub const ENUM_VALUES: &'static [Self] = &[Self::Create, Self::Update, Self::Delete]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::Create => Some("Create"), - Self::Update => Some("Update"), - Self::Delete => Some("Delete"), - _ => None, - } - } -} -impl core::fmt::Debug for InputSetOp { - 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 InputSetOp { - 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 InputSetOp { - type Output = InputSetOp; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); - } -} - -impl flatbuffers::EndianScalar for InputSetOp { - 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 InputSetOp { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - u8::run_verifier(v, pos) - } -} - -impl flatbuffers::SimpleToVerifyInSlice for InputSetOp {} -pub enum InputSetOpV1Offset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct InputSetOpV1<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for InputSetOpV1<'a> { - type Inner = InputSetOpV1<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } -} - -impl<'a> InputSetOpV1<'a> { - pub const VT_ID: flatbuffers::VOffsetT = 4; - pub const VT_OP: flatbuffers::VOffsetT = 6; - pub const VT_INPUTS: flatbuffers::VOffsetT = 8; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - InputSetOpV1 { _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 InputSetOpV1Args<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = InputSetOpV1Builder::new(_fbb); - if let Some(x) = args.inputs { - builder.add_inputs(x); - } - if let Some(x) = args.id { - builder.add_id(x); - } - builder.add_op(args.op); - builder.finish() - } - - pub fn unpack(&self) -> InputSetOpV1T { - let id = self.id().map(|x| x.to_string()); - let op = self.op(); - let inputs = self - .inputs() - .map(|x| x.iter().map(|t| t.unpack()).collect()); - InputSetOpV1T { id, op, inputs } - } - - #[inline] - pub fn id(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(InputSetOpV1::VT_ID, None) - } - } - #[inline] - pub fn op(&self) -> InputSetOp { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(InputSetOpV1::VT_OP, Some(InputSetOp::Create)) - .unwrap() - } - } - #[inline] - pub fn inputs( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(InputSetOpV1::VT_INPUTS, None) - } - } -} - -impl flatbuffers::Verifiable for InputSetOpV1<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>("id", Self::VT_ID, false)? - .visit_field::("op", Self::VT_OP, false)? - .visit_field::>, - >>("inputs", Self::VT_INPUTS, false)? - .finish(); - Ok(()) - } -} -pub struct InputSetOpV1Args<'a> { - pub id: Option>, - pub op: InputSetOp, - pub inputs: Option< - flatbuffers::WIPOffset>>>, - >, -} -impl<'a> Default for InputSetOpV1Args<'a> { - #[inline] - fn default() -> Self { - InputSetOpV1Args { - id: None, - op: InputSetOp::Create, - inputs: None, - } - } -} - -pub struct InputSetOpV1Builder<'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> InputSetOpV1Builder<'a, 'b, A> { - #[inline] - pub fn add_id(&mut self, id: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(InputSetOpV1::VT_ID, id); - } - #[inline] - pub fn add_op(&mut self, op: InputSetOp) { - self.fbb_ - .push_slot::(InputSetOpV1::VT_OP, op, InputSetOp::Create); - } - #[inline] - pub fn add_inputs( - &mut self, - inputs: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(InputSetOpV1::VT_INPUTS, inputs); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> InputSetOpV1Builder<'a, 'b, A> { - let start = _fbb.start_table(); - InputSetOpV1Builder { - 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 InputSetOpV1<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("InputSetOpV1"); - ds.field("id", &self.id()); - ds.field("op", &self.op()); - ds.field("inputs", &self.inputs()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct InputSetOpV1T { - pub id: Option, - pub op: InputSetOp, - pub inputs: Option>, -} -impl Default for InputSetOpV1T { - fn default() -> Self { - Self { - id: None, - op: InputSetOp::Create, - inputs: None, - } - } -} -impl InputSetOpV1T { - pub fn pack<'b, A: flatbuffers::Allocator + 'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>, - ) -> flatbuffers::WIPOffset> { - let id = self.id.as_ref().map(|x| _fbb.create_string(x)); - let op = self.op; - let inputs = self.inputs.as_ref().map(|x| { - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect(); - _fbb.create_vector(&w) - }); - InputSetOpV1::create(_fbb, &InputSetOpV1Args { id, op, inputs }) - } -} -#[inline] -/// Verifies that a buffer of bytes contains a `InputSetOpV1` -/// 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_input_set_op_v1_unchecked`. -pub fn root_as_input_set_op_v1(buf: &[u8]) -> Result { - flatbuffers::root::(buf) -} -#[inline] -/// Verifies that a buffer of bytes contains a size prefixed -/// `InputSetOpV1` 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_input_set_op_v1_unchecked`. -pub fn size_prefixed_root_as_input_set_op_v1( - buf: &[u8], -) -> Result { - flatbuffers::size_prefixed_root::(buf) -} -#[inline] -/// Verifies, with the given options, that a buffer of bytes -/// contains a `InputSetOpV1` 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_input_set_op_v1_unchecked`. -pub fn root_as_input_set_op_v1_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 `InputSetOpV1` 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_input_set_op_v1_unchecked`. -pub fn size_prefixed_root_as_input_set_op_v1_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 InputSetOpV1 and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid `InputSetOpV1`. -pub unsafe fn root_as_input_set_op_v1_unchecked(buf: &[u8]) -> InputSetOpV1 { - flatbuffers::root_unchecked::(buf) -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a size prefixed InputSetOpV1 and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid size prefixed `InputSetOpV1`. -pub unsafe fn size_prefixed_root_as_input_set_op_v1_unchecked(buf: &[u8]) -> InputSetOpV1 { - flatbuffers::size_prefixed_root_unchecked::(buf) -} -#[inline] -pub fn finish_input_set_op_v1_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_input_set_op_v1_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, None); -} diff --git a/schemas-rust/src/input_type_generated.rs b/schemas-rust/src/input_type_generated.rs deleted file mode 100644 index d1c8582..0000000 --- a/schemas-rust/src/input_type_generated.rs +++ /dev/null @@ -1,396 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -// @generated - -use core::cmp::Ordering; -use core::mem; - -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." -)] -pub const ENUM_MIN_PROGRAM_INPUT_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_PROGRAM_INPUT_TYPE: u8 = 3; -#[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_PROGRAM_INPUT_TYPE: [ProgramInputType; 4] = [ - ProgramInputType::Unknown, - ProgramInputType::Public, - ProgramInputType::Private, - ProgramInputType::PublicProof, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct ProgramInputType(pub u8); -#[allow(non_upper_case_globals)] -impl ProgramInputType { - pub const Unknown: Self = Self(0); - pub const Public: Self = Self(1); - pub const Private: Self = Self(2); - pub const PublicProof: Self = Self(3); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 3; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::Unknown, - Self::Public, - Self::Private, - Self::PublicProof, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::Unknown => Some("Unknown"), - Self::Public => Some("Public"), - Self::Private => Some("Private"), - Self::PublicProof => Some("PublicProof"), - _ => None, - } - } -} -impl core::fmt::Debug for ProgramInputType { - 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 ProgramInputType { - 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 ProgramInputType { - type Output = ProgramInputType; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); - } -} - -impl flatbuffers::EndianScalar for ProgramInputType { - 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 ProgramInputType { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - u8::run_verifier(v, pos) - } -} - -impl flatbuffers::SimpleToVerifyInSlice for ProgramInputType {} -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MIN_INPUT_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_INPUT_TYPE: u8 = 8; -#[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_INPUT_TYPE: [InputType; 8] = [ - InputType::Unknown, - InputType::PublicData, - InputType::PublicAccountData, - InputType::PublicUrl, - InputType::Private, - InputType::InputSet, - InputType::PublicProof, - InputType::PrivateLocal, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct InputType(pub u8); -#[allow(non_upper_case_globals)] -impl InputType { - pub const Unknown: Self = Self(0); - pub const PublicData: Self = Self(1); - pub const PublicAccountData: Self = Self(3); - pub const PublicUrl: Self = Self(4); - pub const Private: Self = Self(5); - pub const InputSet: Self = Self(6); - pub const PublicProof: Self = Self(7); - pub const PrivateLocal: Self = Self(8); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 8; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::Unknown, - Self::PublicData, - Self::PublicAccountData, - Self::PublicUrl, - Self::Private, - Self::InputSet, - Self::PublicProof, - Self::PrivateLocal, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::Unknown => Some("Unknown"), - Self::PublicData => Some("PublicData"), - Self::PublicAccountData => Some("PublicAccountData"), - Self::PublicUrl => Some("PublicUrl"), - Self::Private => Some("Private"), - Self::InputSet => Some("InputSet"), - Self::PublicProof => Some("PublicProof"), - Self::PrivateLocal => Some("PrivateLocal"), - _ => None, - } - } -} -impl core::fmt::Debug for InputType { - 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 InputType { - 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 InputType { - type Output = InputType; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); - } -} - -impl flatbuffers::EndianScalar for InputType { - 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 InputType { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - u8::run_verifier(v, pos) - } -} - -impl flatbuffers::SimpleToVerifyInSlice for InputType {} -pub enum InputOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Input<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for Input<'a> { - type Inner = Input<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } -} - -impl<'a> Input<'a> { - pub const VT_INPUT_TYPE: flatbuffers::VOffsetT = 4; - pub const VT_DATA: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Input { _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 InputArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = InputBuilder::new(_fbb); - if let Some(x) = args.data { - builder.add_data(x); - } - builder.add_input_type(args.input_type); - builder.finish() - } - - pub fn unpack(&self) -> InputT { - let input_type = self.input_type(); - let data = self.data().map(|x| x.into_iter().collect()); - InputT { input_type, data } - } - - #[inline] - pub fn input_type(&self) -> InputType { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Input::VT_INPUT_TYPE, Some(InputType::PublicData)) - .unwrap() - } - } - #[inline] - pub fn data(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - Input::VT_DATA, - None, - ) - } - } -} - -impl flatbuffers::Verifiable for Input<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("input_type", Self::VT_INPUT_TYPE, false)? - .visit_field::>>( - "data", - Self::VT_DATA, - false, - )? - .finish(); - Ok(()) - } -} -pub struct InputArgs<'a> { - pub input_type: InputType, - pub data: Option>>, -} -impl<'a> Default for InputArgs<'a> { - #[inline] - fn default() -> Self { - InputArgs { - input_type: InputType::PublicData, - data: None, - } - } -} - -pub struct InputBuilder<'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> InputBuilder<'a, 'b, A> { - #[inline] - pub fn add_input_type(&mut self, input_type: InputType) { - self.fbb_ - .push_slot::(Input::VT_INPUT_TYPE, input_type, InputType::PublicData); - } - #[inline] - pub fn add_data(&mut self, data: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>(Input::VT_DATA, data); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> InputBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - InputBuilder { - 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 Input<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Input"); - ds.field("input_type", &self.input_type()); - ds.field("data", &self.data()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct InputT { - pub input_type: InputType, - pub data: Option>, -} -impl Default for InputT { - fn default() -> Self { - Self { - input_type: InputType::PublicData, - data: None, - } - } -} -impl InputT { - pub fn pack<'b, A: flatbuffers::Allocator + 'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>, - ) -> flatbuffers::WIPOffset> { - let input_type = self.input_type; - let data = self.data.as_ref().map(|x| _fbb.create_vector(x)); - Input::create(_fbb, &InputArgs { input_type, data }) - } -} diff --git a/schemas-rust/src/status_v1_generated.rs b/schemas-rust/src/status_v1_generated.rs deleted file mode 100644 index 942a315..0000000 --- a/schemas-rust/src/status_v1_generated.rs +++ /dev/null @@ -1,627 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -// @generated - -use core::cmp::Ordering; -use core::mem; - -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." -)] -pub const ENUM_MIN_STATUS_TYPES: u8 = 0; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MAX_STATUS_TYPES: 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_STATUS_TYPES: [StatusTypes; 5] = [ - StatusTypes::Unknown, - StatusTypes::Queued, - StatusTypes::Claimed, - StatusTypes::Completed, - StatusTypes::Failed, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct StatusTypes(pub u8); -#[allow(non_upper_case_globals)] -impl StatusTypes { - pub const Unknown: Self = Self(0); - pub const Queued: Self = Self(1); - pub const Claimed: Self = Self(2); - pub const Completed: Self = Self(3); - pub const Failed: Self = Self(4); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 4; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::Unknown, - Self::Queued, - Self::Claimed, - Self::Completed, - Self::Failed, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::Unknown => Some("Unknown"), - Self::Queued => Some("Queued"), - Self::Claimed => Some("Claimed"), - Self::Completed => Some("Completed"), - Self::Failed => Some("Failed"), - _ => None, - } - } -} -impl core::fmt::Debug for StatusTypes { - 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 StatusTypes { - 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 StatusTypes { - type Output = StatusTypes; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); - } -} - -impl flatbuffers::EndianScalar for StatusTypes { - 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 StatusTypes { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - u8::run_verifier(v, pos) - } -} - -impl flatbuffers::SimpleToVerifyInSlice for StatusTypes {} -pub enum StatusV1Offset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct StatusV1<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for StatusV1<'a> { - type Inner = StatusV1<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } -} - -impl<'a> StatusV1<'a> { - pub const VT_EXECUTION_ID: flatbuffers::VOffsetT = 4; - pub const VT_STATUS: flatbuffers::VOffsetT = 6; - pub const VT_PROOF: flatbuffers::VOffsetT = 8; - pub const VT_EXECUTION_DIGEST: flatbuffers::VOffsetT = 10; - pub const VT_INPUT_DIGEST: flatbuffers::VOffsetT = 12; - pub const VT_COMMITTED_OUTPUTS: flatbuffers::VOffsetT = 14; - pub const VT_ASSUMPTION_DIGEST: flatbuffers::VOffsetT = 16; - pub const VT_EXIT_CODE_SYSTEM: flatbuffers::VOffsetT = 18; - pub const VT_EXIT_CODE_USER: flatbuffers::VOffsetT = 20; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - StatusV1 { _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 StatusV1Args<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = StatusV1Builder::new(_fbb); - builder.add_exit_code_user(args.exit_code_user); - builder.add_exit_code_system(args.exit_code_system); - if let Some(x) = args.assumption_digest { - builder.add_assumption_digest(x); - } - if let Some(x) = args.committed_outputs { - builder.add_committed_outputs(x); - } - if let Some(x) = args.input_digest { - builder.add_input_digest(x); - } - if let Some(x) = args.execution_digest { - builder.add_execution_digest(x); - } - if let Some(x) = args.proof { - builder.add_proof(x); - } - if let Some(x) = args.execution_id { - builder.add_execution_id(x); - } - builder.add_status(args.status); - builder.finish() - } - - pub fn unpack(&self) -> StatusV1T { - let execution_id = self.execution_id().map(|x| x.to_string()); - let status = self.status(); - let proof = self.proof().map(|x| x.into_iter().collect()); - let execution_digest = self.execution_digest().map(|x| x.into_iter().collect()); - let input_digest = self.input_digest().map(|x| x.into_iter().collect()); - let committed_outputs = self.committed_outputs().map(|x| x.into_iter().collect()); - let assumption_digest = self.assumption_digest().map(|x| x.into_iter().collect()); - let exit_code_system = self.exit_code_system(); - let exit_code_user = self.exit_code_user(); - StatusV1T { - execution_id, - status, - proof, - execution_digest, - input_digest, - committed_outputs, - assumption_digest, - exit_code_system, - exit_code_user, - } - } - - #[inline] - pub fn execution_id(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(StatusV1::VT_EXECUTION_ID, None) - } - } - #[inline] - pub fn status(&self) -> StatusTypes { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(StatusV1::VT_STATUS, Some(StatusTypes::Unknown)) - .unwrap() - } - } - #[inline] - pub fn proof(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - StatusV1::VT_PROOF, - None, - ) - } - } - #[inline] - pub fn execution_digest(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - StatusV1::VT_EXECUTION_DIGEST, - None, - ) - } - } - #[inline] - pub fn input_digest(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - StatusV1::VT_INPUT_DIGEST, - None, - ) - } - } - #[inline] - pub fn committed_outputs(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - StatusV1::VT_COMMITTED_OUTPUTS, - None, - ) - } - } - #[inline] - pub fn assumption_digest(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - StatusV1::VT_ASSUMPTION_DIGEST, - None, - ) - } - } - #[inline] - pub fn exit_code_system(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(StatusV1::VT_EXIT_CODE_SYSTEM, Some(0)) - .unwrap() - } - } - #[inline] - pub fn exit_code_user(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(StatusV1::VT_EXIT_CODE_USER, Some(0)) - .unwrap() - } - } -} - -impl flatbuffers::Verifiable for StatusV1<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>( - "execution_id", - Self::VT_EXECUTION_ID, - false, - )? - .visit_field::("status", Self::VT_STATUS, false)? - .visit_field::>>( - "proof", - Self::VT_PROOF, - false, - )? - .visit_field::>>( - "execution_digest", - Self::VT_EXECUTION_DIGEST, - false, - )? - .visit_field::>>( - "input_digest", - Self::VT_INPUT_DIGEST, - false, - )? - .visit_field::>>( - "committed_outputs", - Self::VT_COMMITTED_OUTPUTS, - false, - )? - .visit_field::>>( - "assumption_digest", - Self::VT_ASSUMPTION_DIGEST, - false, - )? - .visit_field::("exit_code_system", Self::VT_EXIT_CODE_SYSTEM, false)? - .visit_field::("exit_code_user", Self::VT_EXIT_CODE_USER, false)? - .finish(); - Ok(()) - } -} -pub struct StatusV1Args<'a> { - pub execution_id: Option>, - pub status: StatusTypes, - pub proof: Option>>, - pub execution_digest: Option>>, - pub input_digest: Option>>, - pub committed_outputs: Option>>, - pub assumption_digest: Option>>, - pub exit_code_system: u32, - pub exit_code_user: u32, -} -impl<'a> Default for StatusV1Args<'a> { - #[inline] - fn default() -> Self { - StatusV1Args { - execution_id: None, - status: StatusTypes::Unknown, - proof: None, - execution_digest: None, - input_digest: None, - committed_outputs: None, - assumption_digest: None, - exit_code_system: 0, - exit_code_user: 0, - } - } -} - -pub struct StatusV1Builder<'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> StatusV1Builder<'a, 'b, A> { - #[inline] - pub fn add_execution_id(&mut self, execution_id: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(StatusV1::VT_EXECUTION_ID, execution_id); - } - #[inline] - pub fn add_status(&mut self, status: StatusTypes) { - self.fbb_ - .push_slot::(StatusV1::VT_STATUS, status, StatusTypes::Unknown); - } - #[inline] - pub fn add_proof(&mut self, proof: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>(StatusV1::VT_PROOF, proof); - } - #[inline] - pub fn add_execution_digest( - &mut self, - execution_digest: flatbuffers::WIPOffset>, - ) { - self.fbb_.push_slot_always::>( - StatusV1::VT_EXECUTION_DIGEST, - execution_digest, - ); - } - #[inline] - pub fn add_input_digest( - &mut self, - input_digest: flatbuffers::WIPOffset>, - ) { - self.fbb_ - .push_slot_always::>(StatusV1::VT_INPUT_DIGEST, input_digest); - } - #[inline] - pub fn add_committed_outputs( - &mut self, - committed_outputs: flatbuffers::WIPOffset>, - ) { - self.fbb_.push_slot_always::>( - StatusV1::VT_COMMITTED_OUTPUTS, - committed_outputs, - ); - } - #[inline] - pub fn add_assumption_digest( - &mut self, - assumption_digest: flatbuffers::WIPOffset>, - ) { - self.fbb_.push_slot_always::>( - StatusV1::VT_ASSUMPTION_DIGEST, - assumption_digest, - ); - } - #[inline] - pub fn add_exit_code_system(&mut self, exit_code_system: u32) { - self.fbb_ - .push_slot::(StatusV1::VT_EXIT_CODE_SYSTEM, exit_code_system, 0); - } - #[inline] - pub fn add_exit_code_user(&mut self, exit_code_user: u32) { - self.fbb_ - .push_slot::(StatusV1::VT_EXIT_CODE_USER, exit_code_user, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> StatusV1Builder<'a, 'b, A> { - let start = _fbb.start_table(); - StatusV1Builder { - 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 StatusV1<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("StatusV1"); - ds.field("execution_id", &self.execution_id()); - ds.field("status", &self.status()); - ds.field("proof", &self.proof()); - ds.field("execution_digest", &self.execution_digest()); - ds.field("input_digest", &self.input_digest()); - ds.field("committed_outputs", &self.committed_outputs()); - ds.field("assumption_digest", &self.assumption_digest()); - ds.field("exit_code_system", &self.exit_code_system()); - ds.field("exit_code_user", &self.exit_code_user()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct StatusV1T { - pub execution_id: Option, - pub status: StatusTypes, - pub proof: Option>, - pub execution_digest: Option>, - pub input_digest: Option>, - pub committed_outputs: Option>, - pub assumption_digest: Option>, - pub exit_code_system: u32, - pub exit_code_user: u32, -} -impl Default for StatusV1T { - fn default() -> Self { - Self { - execution_id: None, - status: StatusTypes::Unknown, - proof: None, - execution_digest: None, - input_digest: None, - committed_outputs: None, - assumption_digest: None, - exit_code_system: 0, - exit_code_user: 0, - } - } -} -impl StatusV1T { - pub fn pack<'b, A: flatbuffers::Allocator + 'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>, - ) -> flatbuffers::WIPOffset> { - let execution_id = self.execution_id.as_ref().map(|x| _fbb.create_string(x)); - let status = self.status; - let proof = self.proof.as_ref().map(|x| _fbb.create_vector(x)); - let execution_digest = self - .execution_digest - .as_ref() - .map(|x| _fbb.create_vector(x)); - let input_digest = self.input_digest.as_ref().map(|x| _fbb.create_vector(x)); - let committed_outputs = self - .committed_outputs - .as_ref() - .map(|x| _fbb.create_vector(x)); - let assumption_digest = self - .assumption_digest - .as_ref() - .map(|x| _fbb.create_vector(x)); - let exit_code_system = self.exit_code_system; - let exit_code_user = self.exit_code_user; - StatusV1::create( - _fbb, - &StatusV1Args { - execution_id, - status, - proof, - execution_digest, - input_digest, - committed_outputs, - assumption_digest, - exit_code_system, - exit_code_user, - }, - ) - } -} -#[inline] -/// Verifies that a buffer of bytes contains a `StatusV1` -/// 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_status_v1_unchecked`. -pub fn root_as_status_v1(buf: &[u8]) -> Result { - flatbuffers::root::(buf) -} -#[inline] -/// Verifies that a buffer of bytes contains a size prefixed -/// `StatusV1` 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_status_v1_unchecked`. -pub fn size_prefixed_root_as_status_v1( - buf: &[u8], -) -> Result { - flatbuffers::size_prefixed_root::(buf) -} -#[inline] -/// Verifies, with the given options, that a buffer of bytes -/// contains a `StatusV1` 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_status_v1_unchecked`. -pub fn root_as_status_v1_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 `StatusV1` 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_status_v1_unchecked`. -pub fn size_prefixed_root_as_status_v1_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 StatusV1 and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid `StatusV1`. -pub unsafe fn root_as_status_v1_unchecked(buf: &[u8]) -> StatusV1 { - flatbuffers::root_unchecked::(buf) -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a size prefixed StatusV1 and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid size prefixed `StatusV1`. -pub unsafe fn size_prefixed_root_as_status_v1_unchecked(buf: &[u8]) -> StatusV1 { - flatbuffers::size_prefixed_root_unchecked::(buf) -} -#[inline] -pub fn finish_status_v1_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_status_v1_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - root: flatbuffers::WIPOffset>, -) { - fbb.finish_size_prefixed(root, None); -} diff --git a/schemas/channel_instruction.fbs b/schemas/channel_instruction.fbs index a3d58bc..86ca2a8 100644 --- a/schemas/channel_instruction.fbs +++ b/schemas/channel_instruction.fbs @@ -3,6 +3,7 @@ include "./status_v1.fbs"; include "./deploy_v1.fbs"; include "./claim_v1.fbs"; include "./input_set_op_v1.fbs"; + enum ChannelInstructionIxType: uint8 { ExecuteV1 = 0, StatusV1 = 1, diff --git a/schemas/input_set_op_v1.fbs b/schemas/input_set_op_v1.fbs index 8099ac5..6d678a4 100644 --- a/schemas/input_set_op_v1.fbs +++ b/schemas/input_set_op_v1.fbs @@ -1,4 +1,3 @@ - include "./input_type.fbs"; enum InputSetOp: uint8 {