From 737b7acc59aeb810ce6deba88fffdeb3072e388a Mon Sep 17 00:00:00 2001 From: Jorge Prendes Date: Thu, 8 Jan 2026 12:37:20 +0000 Subject: [PATCH 1/5] Use serde and postcard for serialization in hyperlight-common Signed-off-by: Jorge Prendes --- Cargo.lock | 35 + src/hyperlight_common/Cargo.toml | 2 + .../src/flatbuffer_wrappers/function_call.rs | 220 +----- .../src/flatbuffer_wrappers/function_types.rs | 644 ++-------------- .../src/flatbuffer_wrappers/guest_error.rs | 65 +- .../src/flatbuffer_wrappers/guest_log_data.rs | 78 +- .../flatbuffer_wrappers/guest_log_level.rs | 40 +- .../flatbuffer_wrappers/guest_trace_data.rs | 724 +----------------- .../host_function_definition.rs | 100 +-- .../host_function_details.rs | 78 +- .../src/flatbuffer_wrappers/util.rs | 295 ++----- 11 files changed, 249 insertions(+), 2032 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c1db649c9..1e5156e22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -484,6 +484,15 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" +[[package]] +name = "cobs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1" +dependencies = [ + "thiserror 2.0.17", +] + [[package]] name = "colorchoice" version = "1.0.4" @@ -754,6 +763,18 @@ dependencies = [ "zerocopy 0.7.35", ] +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + [[package]] name = "endian-type" version = "0.1.2" @@ -1373,6 +1394,8 @@ dependencies = [ "arbitrary", "flatbuffers", "log", + "postcard", + "serde", "spin 0.10.0", "thiserror 2.0.17", "tracing", @@ -2601,6 +2624,18 @@ dependencies = [ "portable-atomic", ] +[[package]] +name = "postcard" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" +dependencies = [ + "cobs", + "embedded-io 0.4.0", + "embedded-io 0.6.1", + "serde", +] + [[package]] name = "potential_utf" version = "0.1.4" diff --git a/src/hyperlight_common/Cargo.toml b/src/hyperlight_common/Cargo.toml index 2f54a2f6d..637d75600 100644 --- a/src/hyperlight_common/Cargo.toml +++ b/src/hyperlight_common/Cargo.toml @@ -16,6 +16,8 @@ workspace = true [dependencies] flatbuffers = { version = "25.12.19", default-features = false } +postcard = { version = "1.1.3", default-features = false, features = ["alloc"] } +serde = { version = "1.0.228", default-features = false, features = ["derive", "alloc"] } anyhow = { version = "1.0.100", default-features = false } log = "0.4.29" tracing = { version = "0.1.44", optional = true } diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs b/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs index 056ced8e0..67bdb661b 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs @@ -14,25 +14,19 @@ See the License for the specific language governing permissions and limitations under the License. */ -use alloc::string::{String, ToString}; +use alloc::string::String; use alloc::vec::Vec; -use anyhow::{Error, Result, bail}; -use flatbuffers::{FlatBufferBuilder, WIPOffset, size_prefixed_root}; +use anyhow::{Context, Result, bail}; +use serde::{Deserialize, Serialize}; #[cfg(feature = "tracing")] use tracing::{Span, instrument}; use super::function_types::{ParameterValue, ReturnType}; -use crate::flatbuffers::hyperlight::generated::{ - FunctionCall as FbFunctionCall, FunctionCallArgs as FbFunctionCallArgs, - FunctionCallType as FbFunctionCallType, Parameter, ParameterArgs, - ParameterValue as FbParameterValue, hlbool, hlboolArgs, hldouble, hldoubleArgs, hlfloat, - hlfloatArgs, hlint, hlintArgs, hllong, hllongArgs, hlstring, hlstringArgs, hluint, hluintArgs, - hlulong, hlulongArgs, hlvecbytes, hlvecbytesArgs, -}; +use crate::flatbuffer_wrappers::util::decode; /// The type of function call. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum FunctionCallType { /// The function call is to a guest function. Guest, @@ -41,7 +35,7 @@ pub enum FunctionCallType { } /// `Functioncall` represents a call to a function in the guest or host. -#[derive(Clone)] +#[derive(Clone, Serialize, Deserialize)] pub struct FunctionCall { /// The function name pub function_name: String, @@ -72,154 +66,14 @@ impl FunctionCall { pub fn function_call_type(&self) -> FunctionCallType { self.function_call_type.clone() } - - /// Encodes self into the given builder and returns the encoded data. - /// - /// # Notes - /// - /// The builder should not be reused after a call to encode, since this function - /// does not reset the state of the builder. If you want to reuse the builder, - /// you'll need to reset it first. - pub fn encode<'a>(&self, builder: &'a mut FlatBufferBuilder) -> &'a [u8] { - let function_name = builder.create_string(&self.function_name); - - let function_call_type = match self.function_call_type { - FunctionCallType::Guest => FbFunctionCallType::guest, - FunctionCallType::Host => FbFunctionCallType::host, - }; - - let expected_return_type = self.expected_return_type.into(); - - let parameters = match &self.parameters { - Some(p) if !p.is_empty() => { - let parameter_offsets: Vec> = p - .iter() - .map(|param| match param { - ParameterValue::Int(i) => { - let hlint = hlint::create(builder, &hlintArgs { value: *i }); - Parameter::create( - builder, - &ParameterArgs { - value_type: FbParameterValue::hlint, - value: Some(hlint.as_union_value()), - }, - ) - } - ParameterValue::UInt(ui) => { - let hluint = hluint::create(builder, &hluintArgs { value: *ui }); - Parameter::create( - builder, - &ParameterArgs { - value_type: FbParameterValue::hluint, - value: Some(hluint.as_union_value()), - }, - ) - } - ParameterValue::Long(l) => { - let hllong = hllong::create(builder, &hllongArgs { value: *l }); - Parameter::create( - builder, - &ParameterArgs { - value_type: FbParameterValue::hllong, - value: Some(hllong.as_union_value()), - }, - ) - } - ParameterValue::ULong(ul) => { - let hlulong = hlulong::create(builder, &hlulongArgs { value: *ul }); - Parameter::create( - builder, - &ParameterArgs { - value_type: FbParameterValue::hlulong, - value: Some(hlulong.as_union_value()), - }, - ) - } - ParameterValue::Float(f) => { - let hlfloat = hlfloat::create(builder, &hlfloatArgs { value: *f }); - Parameter::create( - builder, - &ParameterArgs { - value_type: FbParameterValue::hlfloat, - value: Some(hlfloat.as_union_value()), - }, - ) - } - ParameterValue::Double(d) => { - let hldouble = hldouble::create(builder, &hldoubleArgs { value: *d }); - Parameter::create( - builder, - &ParameterArgs { - value_type: FbParameterValue::hldouble, - value: Some(hldouble.as_union_value()), - }, - ) - } - ParameterValue::Bool(b) => { - let hlbool = hlbool::create(builder, &hlboolArgs { value: *b }); - Parameter::create( - builder, - &ParameterArgs { - value_type: FbParameterValue::hlbool, - value: Some(hlbool.as_union_value()), - }, - ) - } - ParameterValue::String(s) => { - let val = builder.create_string(s.as_str()); - let hlstring = - hlstring::create(builder, &hlstringArgs { value: Some(val) }); - Parameter::create( - builder, - &ParameterArgs { - value_type: FbParameterValue::hlstring, - value: Some(hlstring.as_union_value()), - }, - ) - } - ParameterValue::VecBytes(v) => { - let vec_bytes = builder.create_vector(v); - let hlvecbytes = hlvecbytes::create( - builder, - &hlvecbytesArgs { - value: Some(vec_bytes), - }, - ); - Parameter::create( - builder, - &ParameterArgs { - value_type: FbParameterValue::hlvecbytes, - value: Some(hlvecbytes.as_union_value()), - }, - ) - } - }) - .collect(); - Some(builder.create_vector(¶meter_offsets)) - } - _ => None, - }; - - let function_call = FbFunctionCall::create( - builder, - &FbFunctionCallArgs { - function_name: Some(function_name), - parameters, - function_call_type, - expected_return_type, - }, - ); - builder.finish_size_prefixed(function_call, None); - builder.finished_data() - } } #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] pub fn validate_guest_function_call_buffer(function_call_buffer: &[u8]) -> Result<()> { - let guest_function_call_fb = size_prefixed_root::(function_call_buffer) - .map_err(|e| anyhow::anyhow!("Error reading function call buffer: {:?}", e))?; - match guest_function_call_fb.function_call_type() { - FbFunctionCallType::guest => Ok(()), + let guest_function_call: FunctionCall = + decode(function_call_buffer).context("Error reading function call buffer")?; + match guest_function_call.function_call_type { + FunctionCallType::Guest => Ok(()), other => { bail!("Invalid function call type: {:?}", other); } @@ -228,61 +82,28 @@ pub fn validate_guest_function_call_buffer(function_call_buffer: &[u8]) -> Resul #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] pub fn validate_host_function_call_buffer(function_call_buffer: &[u8]) -> Result<()> { - let host_function_call_fb = size_prefixed_root::(function_call_buffer) - .map_err(|e| anyhow::anyhow!("Error reading function call buffer: {:?}", e))?; - match host_function_call_fb.function_call_type() { - FbFunctionCallType::host => Ok(()), + let host_function_call: FunctionCall = + decode(function_call_buffer).context("Error reading function call buffer")?; + match host_function_call.function_call_type { + FunctionCallType::Host => Ok(()), other => { bail!("Invalid function call type: {:?}", other); } } } -impl TryFrom<&[u8]> for FunctionCall { - type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(value: &[u8]) -> Result { - let function_call_fb = size_prefixed_root::(value) - .map_err(|e| anyhow::anyhow!("Error reading function call buffer: {:?}", e))?; - let function_name = function_call_fb.function_name(); - let function_call_type = match function_call_fb.function_call_type() { - FbFunctionCallType::guest => FunctionCallType::Guest, - FbFunctionCallType::host => FunctionCallType::Host, - other => { - bail!("Invalid function call type: {:?}", other); - } - }; - let expected_return_type = function_call_fb.expected_return_type().try_into()?; - - let parameters = function_call_fb - .parameters() - .map(|v| { - v.iter() - .map(|p| p.try_into()) - .collect::>>() - }) - .transpose()?; - - Ok(Self { - function_name: function_name.to_string(), - parameters, - function_call_type, - expected_return_type, - }) - } -} - #[cfg(test)] mod tests { + use alloc::string::ToString; use alloc::vec; use super::*; use crate::flatbuffer_wrappers::function_types::ReturnType; + use crate::flatbuffer_wrappers::util::encode; #[test] fn read_from_flatbuffer() -> Result<()> { - let mut builder = FlatBufferBuilder::new(); - let test_data = FunctionCall::new( + let value = FunctionCall::new( "PrintTwelveArgs".to_string(), Some(vec![ ParameterValue::String("1".to_string()), @@ -300,10 +121,11 @@ mod tests { ]), FunctionCallType::Guest, ReturnType::Int, - ) - .encode(&mut builder); + ); + + let test_data = encode(&value)?; - let function_call = FunctionCall::try_from(test_data)?; + let function_call: FunctionCall = decode(&test_data)?; assert_eq!(function_call.function_name, "PrintTwelveArgs"); assert!(function_call.parameters.is_some()); let parameters = function_call.parameters.unwrap(); diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs b/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs index 42c7ff823..7c95fa450 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs @@ -14,127 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -use alloc::string::{String, ToString}; +use alloc::string::String; use alloc::vec::Vec; -use anyhow::{Error, Result, anyhow, bail}; -use flatbuffers::size_prefixed_root; +use anyhow::{Error, Result, bail}; +use serde::{Deserialize, Serialize}; #[cfg(feature = "tracing")] use tracing::{Span, instrument}; use super::guest_error::GuestError; -use crate::flatbuffers::hyperlight::generated::{ - FunctionCallResult as FbFunctionCallResult, FunctionCallResultArgs as FbFunctionCallResultArgs, - FunctionCallResultType, Parameter, ParameterType as FbParameterType, - ParameterValue as FbParameterValue, ReturnType as FbReturnType, ReturnValue as FbReturnValue, - ReturnValueBox, ReturnValueBoxArgs, hlbool, hlboolArgs, hldouble, hldoubleArgs, hlfloat, - hlfloatArgs, hlint, hlintArgs, hllong, hllongArgs, hlsizeprefixedbuffer, - hlsizeprefixedbufferArgs, hlstring, hlstringArgs, hluint, hluintArgs, hlulong, hlulongArgs, - hlvoid, hlvoidArgs, -}; +#[derive(Serialize, Deserialize)] pub struct FunctionCallResult(core::result::Result); impl FunctionCallResult { - /// Encodes self into the given builder and returns the encoded data. - /// - /// # Notes - /// - /// The builder should not be reused after a call to encode, since this function - /// does not reset the state of the builder. If you want to reuse the builder, - /// you'll need to reset it first. - pub fn encode<'a>(&self, builder: &'a mut flatbuffers::FlatBufferBuilder) -> &'a [u8] { - match &self.0 { - Ok(rv) => { - // Encode ReturnValue as ReturnValueBox - let (value, value_type) = match rv { - ReturnValue::Int(i) => { - let off = hlint::create(builder, &hlintArgs { value: *i }); - (Some(off.as_union_value()), FbReturnValue::hlint) - } - ReturnValue::UInt(ui) => { - let off = hluint::create(builder, &hluintArgs { value: *ui }); - (Some(off.as_union_value()), FbReturnValue::hluint) - } - ReturnValue::Long(l) => { - let off = hllong::create(builder, &hllongArgs { value: *l }); - (Some(off.as_union_value()), FbReturnValue::hllong) - } - ReturnValue::ULong(ul) => { - let off = hlulong::create(builder, &hlulongArgs { value: *ul }); - (Some(off.as_union_value()), FbReturnValue::hlulong) - } - ReturnValue::Float(f) => { - let off = hlfloat::create(builder, &hlfloatArgs { value: *f }); - (Some(off.as_union_value()), FbReturnValue::hlfloat) - } - ReturnValue::Double(d) => { - let off = hldouble::create(builder, &hldoubleArgs { value: *d }); - (Some(off.as_union_value()), FbReturnValue::hldouble) - } - ReturnValue::Bool(b) => { - let off = hlbool::create(builder, &hlboolArgs { value: *b }); - (Some(off.as_union_value()), FbReturnValue::hlbool) - } - ReturnValue::String(s) => { - let val = builder.create_string(s.as_str()); - let off = hlstring::create(builder, &hlstringArgs { value: Some(val) }); - (Some(off.as_union_value()), FbReturnValue::hlstring) - } - ReturnValue::VecBytes(v) => { - let val = builder.create_vector(v); - let off = hlsizeprefixedbuffer::create( - builder, - &hlsizeprefixedbufferArgs { - value: Some(val), - size: v.len() as i32, - }, - ); - ( - Some(off.as_union_value()), - FbReturnValue::hlsizeprefixedbuffer, - ) - } - ReturnValue::Void(()) => { - let off = hlvoid::create(builder, &hlvoidArgs {}); - (Some(off.as_union_value()), FbReturnValue::hlvoid) - } - }; - let rv_box = - ReturnValueBox::create(builder, &ReturnValueBoxArgs { value, value_type }); - let fcr = FbFunctionCallResult::create( - builder, - &FbFunctionCallResultArgs { - result: Some(rv_box.as_union_value()), - result_type: FunctionCallResultType::ReturnValueBox, - }, - ); - builder.finish_size_prefixed(fcr, None); - builder.finished_data() - } - Err(ge) => { - // Encode GuestError - let code: crate::flatbuffers::hyperlight::generated::ErrorCode = ge.code.into(); - let msg = builder.create_string(&ge.message); - let guest_error = crate::flatbuffers::hyperlight::generated::GuestError::create( - builder, - &crate::flatbuffers::hyperlight::generated::GuestErrorArgs { - code, - message: Some(msg), - }, - ); - let fcr = FbFunctionCallResult::create( - builder, - &FbFunctionCallResultArgs { - result: Some(guest_error.as_union_value()), - result_type: FunctionCallResultType::GuestError, - }, - ); - builder.finish_size_prefixed(fcr, None); - builder.finished_data() - } - } - } pub fn new(value: core::result::Result) -> Self { FunctionCallResult(value) } @@ -144,47 +37,9 @@ impl FunctionCallResult { } } -impl TryFrom<&[u8]> for FunctionCallResult { - type Error = Error; - - fn try_from(value: &[u8]) -> Result { - let function_call_result_fb = size_prefixed_root::(value) - .map_err(|e| anyhow!("Failed to get FunctionCallResult from bytes: {:?}", e))?; - - match function_call_result_fb.result_type() { - FunctionCallResultType::ReturnValueBox => { - let boxed = function_call_result_fb - .result_as_return_value_box() - .ok_or_else(|| { - anyhow!("Failed to get ReturnValueBox from function call result") - })?; - let return_value = ReturnValue::try_from(boxed)?; - Ok(FunctionCallResult(Ok(return_value))) - } - FunctionCallResultType::GuestError => { - let guest_error_table = function_call_result_fb - .result_as_guest_error() - .ok_or_else(|| anyhow!("Failed to get GuestError from function call result"))?; - let code = guest_error_table.code(); - let message = guest_error_table - .message() - .map(|s| s.to_string()) - .unwrap_or_default(); - Ok(FunctionCallResult(Err(GuestError::new( - code.into(), - message, - )))) - } - other => { - bail!("Unexpected function call result type: {:?}", other) - } - } - } -} - /// Supported parameter types with values for function calling. #[cfg_attr(feature = "fuzzing", derive(arbitrary::Arbitrary))] -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum ParameterValue { /// i32 Int(i32), @@ -207,7 +62,7 @@ pub enum ParameterValue { } /// Supported parameter types for function calling. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[repr(C)] pub enum ParameterType { /// i32 @@ -231,7 +86,7 @@ pub enum ParameterType { } /// Supported return types with values from function calling. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum ReturnValue { /// i32 Int(i32), @@ -257,7 +112,7 @@ pub enum ReturnValue { /// Supported return types from function calling. #[cfg_attr(feature = "fuzzing", derive(arbitrary::Arbitrary))] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Default, Serialize, Deserialize)] #[repr(C)] pub enum ReturnType { /// i32 @@ -300,126 +155,6 @@ impl From<&ParameterValue> for ParameterType { } } -impl TryFrom> for ParameterValue { - type Error = Error; - - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(param: Parameter<'_>) -> Result { - let value = param.value_type(); - let result = match value { - FbParameterValue::hlint => param - .value_as_hlint() - .map(|hlint| ParameterValue::Int(hlint.value())), - FbParameterValue::hluint => param - .value_as_hluint() - .map(|hluint| ParameterValue::UInt(hluint.value())), - FbParameterValue::hllong => param - .value_as_hllong() - .map(|hllong| ParameterValue::Long(hllong.value())), - FbParameterValue::hlulong => param - .value_as_hlulong() - .map(|hlulong| ParameterValue::ULong(hlulong.value())), - FbParameterValue::hlfloat => param - .value_as_hlfloat() - .map(|hlfloat| ParameterValue::Float(hlfloat.value())), - FbParameterValue::hldouble => param - .value_as_hldouble() - .map(|hldouble| ParameterValue::Double(hldouble.value())), - FbParameterValue::hlbool => param - .value_as_hlbool() - .map(|hlbool| ParameterValue::Bool(hlbool.value())), - FbParameterValue::hlstring => param.value_as_hlstring().map(|hlstring| { - ParameterValue::String(hlstring.value().unwrap_or_default().to_string()) - }), - FbParameterValue::hlvecbytes => param.value_as_hlvecbytes().map(|hlvecbytes| { - ParameterValue::VecBytes(hlvecbytes.value().unwrap_or_default().bytes().to_vec()) - }), - other => { - bail!("Unexpected flatbuffer parameter value type: {:?}", other); - } - }; - result.ok_or_else(|| anyhow!("Failed to get parameter value")) - } -} - -impl From for FbParameterType { - #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] - fn from(value: ParameterType) -> Self { - match value { - ParameterType::Int => FbParameterType::hlint, - ParameterType::UInt => FbParameterType::hluint, - ParameterType::Long => FbParameterType::hllong, - ParameterType::ULong => FbParameterType::hlulong, - ParameterType::Float => FbParameterType::hlfloat, - ParameterType::Double => FbParameterType::hldouble, - ParameterType::String => FbParameterType::hlstring, - ParameterType::Bool => FbParameterType::hlbool, - ParameterType::VecBytes => FbParameterType::hlvecbytes, - } - } -} - -impl From for FbReturnType { - #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] - fn from(value: ReturnType) -> Self { - match value { - ReturnType::Int => FbReturnType::hlint, - ReturnType::UInt => FbReturnType::hluint, - ReturnType::Long => FbReturnType::hllong, - ReturnType::ULong => FbReturnType::hlulong, - ReturnType::Float => FbReturnType::hlfloat, - ReturnType::Double => FbReturnType::hldouble, - ReturnType::String => FbReturnType::hlstring, - ReturnType::Bool => FbReturnType::hlbool, - ReturnType::Void => FbReturnType::hlvoid, - ReturnType::VecBytes => FbReturnType::hlsizeprefixedbuffer, - } - } -} - -impl TryFrom for ParameterType { - type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(value: FbParameterType) -> Result { - match value { - FbParameterType::hlint => Ok(ParameterType::Int), - FbParameterType::hluint => Ok(ParameterType::UInt), - FbParameterType::hllong => Ok(ParameterType::Long), - FbParameterType::hlulong => Ok(ParameterType::ULong), - FbParameterType::hlfloat => Ok(ParameterType::Float), - FbParameterType::hldouble => Ok(ParameterType::Double), - FbParameterType::hlstring => Ok(ParameterType::String), - FbParameterType::hlbool => Ok(ParameterType::Bool), - FbParameterType::hlvecbytes => Ok(ParameterType::VecBytes), - _ => { - bail!("Unexpected flatbuffer parameter type: {:?}", value) - } - } - } -} - -impl TryFrom for ReturnType { - type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(value: FbReturnType) -> Result { - match value { - FbReturnType::hlint => Ok(ReturnType::Int), - FbReturnType::hluint => Ok(ReturnType::UInt), - FbReturnType::hllong => Ok(ReturnType::Long), - FbReturnType::hlulong => Ok(ReturnType::ULong), - FbReturnType::hlfloat => Ok(ReturnType::Float), - FbReturnType::hldouble => Ok(ReturnType::Double), - FbReturnType::hlstring => Ok(ReturnType::String), - FbReturnType::hlbool => Ok(ReturnType::Bool), - FbReturnType::hlvoid => Ok(ReturnType::Void), - FbReturnType::hlsizeprefixedbuffer => Ok(ReturnType::VecBytes), - _ => { - bail!("Unexpected flatbuffer return type: {:?}", value) - } - } - } -} - impl TryFrom for i32 { type Error = Error; #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] @@ -667,318 +402,103 @@ impl TryFrom for () { } } -impl TryFrom> for ReturnValue { - type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(return_value_box: ReturnValueBox<'_>) -> Result { - match return_value_box.value_type() { - FbReturnValue::hlint => { - let hlint = return_value_box - .value_as_hlint() - .ok_or_else(|| anyhow!("Failed to get hlint from return value"))?; - Ok(ReturnValue::Int(hlint.value())) - } - FbReturnValue::hluint => { - let hluint = return_value_box - .value_as_hluint() - .ok_or_else(|| anyhow!("Failed to get hluint from return value"))?; - Ok(ReturnValue::UInt(hluint.value())) - } - FbReturnValue::hllong => { - let hllong = return_value_box - .value_as_hllong() - .ok_or_else(|| anyhow!("Failed to get hllong from return value"))?; - Ok(ReturnValue::Long(hllong.value())) - } - FbReturnValue::hlulong => { - let hlulong = return_value_box - .value_as_hlulong() - .ok_or_else(|| anyhow!("Failed to get hlulong from return value"))?; - Ok(ReturnValue::ULong(hlulong.value())) - } - FbReturnValue::hlfloat => { - let hlfloat = return_value_box - .value_as_hlfloat() - .ok_or_else(|| anyhow!("Failed to get hlfloat from return value"))?; - Ok(ReturnValue::Float(hlfloat.value())) - } - FbReturnValue::hldouble => { - let hldouble = return_value_box - .value_as_hldouble() - .ok_or_else(|| anyhow!("Failed to get hldouble from return value"))?; - Ok(ReturnValue::Double(hldouble.value())) - } - FbReturnValue::hlbool => { - let hlbool = return_value_box - .value_as_hlbool() - .ok_or_else(|| anyhow!("Failed to get hlbool from return value"))?; - Ok(ReturnValue::Bool(hlbool.value())) - } - FbReturnValue::hlstring => { - let hlstring = match return_value_box.value_as_hlstring() { - Some(hlstring) => hlstring.value().map(|v| v.to_string()), - None => None, - }; - Ok(ReturnValue::String(hlstring.unwrap_or("".to_string()))) - } - FbReturnValue::hlvoid => Ok(ReturnValue::Void(())), - FbReturnValue::hlsizeprefixedbuffer => { - let hlvecbytes = match return_value_box.value_as_hlsizeprefixedbuffer() { - Some(hlvecbytes) => hlvecbytes - .value() - .map(|val| val.iter().collect::>()), - None => None, - }; - Ok(ReturnValue::VecBytes(hlvecbytes.unwrap_or(Vec::new()))) - } - other => { - bail!("Unexpected flatbuffer return value type: {:?}", other) - } - } +impl From<()> for ReturnValue { + #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + fn from(_: ()) -> Self { + ReturnValue::Void(()) } } - -impl TryFrom<&ReturnValue> for Vec { - type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(value: &ReturnValue) -> Result> { - let mut builder = flatbuffers::FlatBufferBuilder::new(); - let result_bytes = match value { - ReturnValue::Int(i) => { - let hlint_off = hlint::create(&mut builder, &hlintArgs { value: *i }); - let rv_box = ReturnValueBox::create( - &mut builder, - &ReturnValueBoxArgs { - value: Some(hlint_off.as_union_value()), - value_type: FbReturnValue::hlint, - }, - ); - let fcr = FbFunctionCallResult::create( - &mut builder, - &FbFunctionCallResultArgs { - result: Some(rv_box.as_union_value()), - result_type: FunctionCallResultType::ReturnValueBox, - }, - ); - builder.finish_size_prefixed(fcr, None); - builder.finished_data().to_vec() - } - ReturnValue::UInt(ui) => { - let off = hluint::create(&mut builder, &hluintArgs { value: *ui }); - let rv_box = ReturnValueBox::create( - &mut builder, - &ReturnValueBoxArgs { - value: Some(off.as_union_value()), - value_type: FbReturnValue::hluint, - }, - ); - let fcr = FbFunctionCallResult::create( - &mut builder, - &FbFunctionCallResultArgs { - result: Some(rv_box.as_union_value()), - result_type: FunctionCallResultType::ReturnValueBox, - }, - ); - builder.finish_size_prefixed(fcr, None); - builder.finished_data().to_vec() - } - ReturnValue::Long(l) => { - let off = hllong::create(&mut builder, &hllongArgs { value: *l }); - let rv_box = ReturnValueBox::create( - &mut builder, - &ReturnValueBoxArgs { - value: Some(off.as_union_value()), - value_type: FbReturnValue::hllong, - }, - ); - let fcr = FbFunctionCallResult::create( - &mut builder, - &FbFunctionCallResultArgs { - result: Some(rv_box.as_union_value()), - result_type: FunctionCallResultType::ReturnValueBox, - }, - ); - builder.finish_size_prefixed(fcr, None); - builder.finished_data().to_vec() - } - ReturnValue::ULong(ul) => { - let off = hlulong::create(&mut builder, &hlulongArgs { value: *ul }); - let rv_box = ReturnValueBox::create( - &mut builder, - &ReturnValueBoxArgs { - value: Some(off.as_union_value()), - value_type: FbReturnValue::hlulong, - }, - ); - let fcr = FbFunctionCallResult::create( - &mut builder, - &FbFunctionCallResultArgs { - result: Some(rv_box.as_union_value()), - result_type: FunctionCallResultType::ReturnValueBox, - }, - ); - builder.finish_size_prefixed(fcr, None); - builder.finished_data().to_vec() - } - ReturnValue::Float(f) => { - let off = hlfloat::create(&mut builder, &hlfloatArgs { value: *f }); - let rv_box = ReturnValueBox::create( - &mut builder, - &ReturnValueBoxArgs { - value: Some(off.as_union_value()), - value_type: FbReturnValue::hlfloat, - }, - ); - let fcr = FbFunctionCallResult::create( - &mut builder, - &FbFunctionCallResultArgs { - result: Some(rv_box.as_union_value()), - result_type: FunctionCallResultType::ReturnValueBox, - }, - ); - builder.finish_size_prefixed(fcr, None); - builder.finished_data().to_vec() - } - ReturnValue::Double(d) => { - let off = hldouble::create(&mut builder, &hldoubleArgs { value: *d }); - let rv_box = ReturnValueBox::create( - &mut builder, - &ReturnValueBoxArgs { - value: Some(off.as_union_value()), - value_type: FbReturnValue::hldouble, - }, - ); - let fcr = FbFunctionCallResult::create( - &mut builder, - &FbFunctionCallResultArgs { - result: Some(rv_box.as_union_value()), - result_type: FunctionCallResultType::ReturnValueBox, - }, - ); - builder.finish_size_prefixed(fcr, None); - builder.finished_data().to_vec() - } - ReturnValue::Bool(b) => { - let off = hlbool::create(&mut builder, &hlboolArgs { value: *b }); - let rv_box = ReturnValueBox::create( - &mut builder, - &ReturnValueBoxArgs { - value: Some(off.as_union_value()), - value_type: FbReturnValue::hlbool, - }, - ); - let fcr = FbFunctionCallResult::create( - &mut builder, - &FbFunctionCallResultArgs { - result: Some(rv_box.as_union_value()), - result_type: FunctionCallResultType::ReturnValueBox, - }, - ); - builder.finish_size_prefixed(fcr, None); - builder.finished_data().to_vec() - } - ReturnValue::String(s) => { - let off = { - let val = builder.create_string(s.as_str()); - hlstring::create(&mut builder, &hlstringArgs { value: Some(val) }) - }; - let rv_box = ReturnValueBox::create( - &mut builder, - &ReturnValueBoxArgs { - value: Some(off.as_union_value()), - value_type: FbReturnValue::hlstring, - }, - ); - let fcr = FbFunctionCallResult::create( - &mut builder, - &FbFunctionCallResultArgs { - result: Some(rv_box.as_union_value()), - result_type: FunctionCallResultType::ReturnValueBox, - }, - ); - builder.finish_size_prefixed(fcr, None); - builder.finished_data().to_vec() - } - ReturnValue::VecBytes(v) => { - let off = { - let val = builder.create_vector(v.as_slice()); - hlsizeprefixedbuffer::create( - &mut builder, - &hlsizeprefixedbufferArgs { - value: Some(val), - size: v.len() as i32, - }, - ) - }; - let rv_box = ReturnValueBox::create( - &mut builder, - &ReturnValueBoxArgs { - value: Some(off.as_union_value()), - value_type: FbReturnValue::hlsizeprefixedbuffer, - }, - ); - let fcr = FbFunctionCallResult::create( - &mut builder, - &FbFunctionCallResultArgs { - result: Some(rv_box.as_union_value()), - result_type: FunctionCallResultType::ReturnValueBox, - }, - ); - builder.finish_size_prefixed(fcr, None); - builder.finished_data().to_vec() - } - ReturnValue::Void(()) => { - let off = hlvoid::create(&mut builder, &hlvoidArgs {}); - let rv_box = ReturnValueBox::create( - &mut builder, - &ReturnValueBoxArgs { - value: Some(off.as_union_value()), - value_type: FbReturnValue::hlvoid, - }, - ); - let fcr = FbFunctionCallResult::create( - &mut builder, - &FbFunctionCallResultArgs { - result: Some(rv_box.as_union_value()), - result_type: FunctionCallResultType::ReturnValueBox, - }, - ); - builder.finish_size_prefixed(fcr, None); - builder.finished_data().to_vec() - } - }; - - Ok(result_bytes) +impl From for ReturnValue { + #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + fn from(val: i32) -> Self { + ReturnValue::Int(val) + } +} +impl From for ReturnValue { + #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + fn from(val: u32) -> Self { + ReturnValue::UInt(val) + } +} +impl From for ReturnValue { + #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + fn from(val: i64) -> Self { + ReturnValue::Long(val) + } +} +impl From for ReturnValue { + #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + fn from(val: u64) -> Self { + ReturnValue::ULong(val) + } +} +impl From for ReturnValue { + #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + fn from(val: f32) -> Self { + ReturnValue::Float(val) + } +} +impl From for ReturnValue { + #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + fn from(val: f64) -> Self { + ReturnValue::Double(val) + } +} +impl From for ReturnValue { + #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + fn from(val: String) -> Self { + ReturnValue::String(val) + } +} +impl From for ReturnValue { + #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + fn from(val: bool) -> Self { + ReturnValue::Bool(val) + } +} +impl From> for ReturnValue { + #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + fn from(val: Vec) -> Self { + ReturnValue::VecBytes(val) + } +} +impl From<&[u8]> for ReturnValue { + #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + fn from(val: &[u8]) -> Self { + ReturnValue::VecBytes(val.to_vec()) + } +} +impl From<&str> for ReturnValue { + #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + fn from(val: &str) -> Self { + ReturnValue::String(val.into()) } } #[cfg(test)] mod tests { - use flatbuffers::FlatBufferBuilder; + use alloc::string::ToString; use super::super::guest_error::ErrorCode; use super::*; + use crate::flatbuffer_wrappers::util::{decode, encode}; #[test] fn encode_success_result() { - let mut builder = FlatBufferBuilder::new(); - let test_data = FunctionCallResult::new(Ok(ReturnValue::Int(42))).encode(&mut builder); - - let function_call_result = FunctionCallResult::try_from(test_data).unwrap(); + let test_data = encode(&FunctionCallResult::new(Ok(ReturnValue::Int(42)))).unwrap(); + let function_call_result: FunctionCallResult = decode(&test_data).unwrap(); let result = function_call_result.into_inner().unwrap(); assert_eq!(result, ReturnValue::Int(42)); } #[test] fn encode_error_result() { - let mut builder = FlatBufferBuilder::new(); let test_error = GuestError::new( ErrorCode::GuestFunctionNotFound, "Function not found".to_string(), ); - let test_data = FunctionCallResult::new(Err(test_error.clone())).encode(&mut builder); - - let function_call_result = FunctionCallResult::try_from(test_data).unwrap(); + let test_data = encode(&FunctionCallResult::new(Err(test_error.clone()))).unwrap(); + let function_call_result: FunctionCallResult = decode(&test_data).unwrap(); let error = function_call_result.into_inner().unwrap_err(); assert_eq!(error.code, test_error.code); assert_eq!(error.message, test_error.message); diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs b/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs index b3d1f457e..a2e5cac0a 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs @@ -14,16 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -extern crate flatbuffers; - use alloc::string::{String, ToString}; +use serde::{Deserialize, Serialize}; #[cfg(feature = "tracing")] use tracing::{Span, instrument}; -use crate::flatbuffers::hyperlight::generated::ErrorCode as FbErrorCode; - -#[derive(Debug, Clone, Copy, Eq, PartialEq)] +#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize)] #[repr(C)] /// `ErrorCode` represents an error that occurred in the Hyperlight Guest. pub enum ErrorCode { @@ -46,62 +43,6 @@ pub enum ErrorCode { HostFunctionError = 17, } -impl From for FbErrorCode { - fn from(error_code: ErrorCode) -> Self { - match error_code { - ErrorCode::NoError => Self::NoError, - ErrorCode::UnsupportedParameterType => Self::UnsupportedParameterType, - ErrorCode::GuestFunctionNameNotProvided => Self::GuestFunctionNameNotProvided, - ErrorCode::GuestFunctionNotFound => Self::GuestFunctionNotFound, - ErrorCode::GuestFunctionIncorrecNoOfParameters => { - Self::GuestFunctionIncorrecNoOfParameters - } - ErrorCode::GispatchFunctionPointerNotSet => Self::GispatchFunctionPointerNotSet, - ErrorCode::OutbError => Self::OutbError, - ErrorCode::UnknownError => Self::UnknownError, - ErrorCode::StackOverflow => Self::StackOverflow, - ErrorCode::GsCheckFailed => Self::GsCheckFailed, - ErrorCode::TooManyGuestFunctions => Self::TooManyGuestFunctions, - ErrorCode::FailureInDlmalloc => Self::FailureInDlmalloc, - ErrorCode::MallocFailed => Self::MallocFailed, - ErrorCode::GuestFunctionParameterTypeMismatch => { - Self::GuestFunctionParameterTypeMismatch - } - ErrorCode::GuestError => Self::GuestError, - ErrorCode::ArrayLengthParamIsMissing => Self::ArrayLengthParamIsMissing, - ErrorCode::HostFunctionError => Self::HostError, - } - } -} - -impl From for ErrorCode { - fn from(error_code: FbErrorCode) -> Self { - match error_code { - FbErrorCode::NoError => Self::NoError, - FbErrorCode::UnsupportedParameterType => Self::UnsupportedParameterType, - FbErrorCode::GuestFunctionNameNotProvided => Self::GuestFunctionNameNotProvided, - FbErrorCode::GuestFunctionNotFound => Self::GuestFunctionNotFound, - FbErrorCode::GuestFunctionIncorrecNoOfParameters => { - Self::GuestFunctionIncorrecNoOfParameters - } - FbErrorCode::GispatchFunctionPointerNotSet => Self::GispatchFunctionPointerNotSet, - FbErrorCode::OutbError => Self::OutbError, - FbErrorCode::StackOverflow => Self::StackOverflow, - FbErrorCode::GsCheckFailed => Self::GsCheckFailed, - FbErrorCode::TooManyGuestFunctions => Self::TooManyGuestFunctions, - FbErrorCode::FailureInDlmalloc => Self::FailureInDlmalloc, - FbErrorCode::MallocFailed => Self::MallocFailed, - FbErrorCode::GuestFunctionParameterTypeMismatch => { - Self::GuestFunctionParameterTypeMismatch - } - FbErrorCode::GuestError => Self::GuestError, - FbErrorCode::ArrayLengthParamIsMissing => Self::ArrayLengthParamIsMissing, - FbErrorCode::HostError => Self::HostFunctionError, - _ => Self::UnknownError, - } - } -} - impl From for ErrorCode { fn from(error_code: u64) -> Self { match error_code { @@ -180,7 +121,7 @@ impl From for String { } /// `GuestError` represents an error that occurred in the Hyperlight Guest. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct GuestError { /// The error code. pub code: ErrorCode, diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs index cc27525a2..03b201f45 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs @@ -14,21 +14,16 @@ See the License for the specific language governing permissions and limitations under the License. */ -use alloc::string::{String, ToString}; -use alloc::vec::Vec; +use alloc::string::String; -use anyhow::{Error, Result, anyhow}; -use flatbuffers::size_prefixed_root; +use serde::{Deserialize, Serialize}; #[cfg(feature = "tracing")] use tracing::{Span, instrument}; use super::guest_log_level::LogLevel; -use crate::flatbuffers::hyperlight::generated::{ - GuestLogData as FbGuestLogData, GuestLogDataArgs as FbGuestLogDataArgs, LogLevel as FbLogLevel, -}; /// The guest log data for a VM sandbox -#[derive(Eq, PartialEq, Debug, Clone)] +#[derive(Eq, PartialEq, Debug, Clone, Serialize, Deserialize)] #[allow(missing_docs)] pub struct GuestLogData { pub message: String, @@ -59,70 +54,3 @@ impl GuestLogData { } } } - -impl TryFrom<&[u8]> for GuestLogData { - type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(raw_bytes: &[u8]) -> Result { - let gld_gen = size_prefixed_root::(raw_bytes) - .map_err(|e| anyhow!("Error while reading GuestLogData: {:?}", e))?; - let message = convert_generated_option("message", gld_gen.message())?; - let source = convert_generated_option("source", gld_gen.source())?; - let level = LogLevel::try_from(&gld_gen.level())?; - let caller = convert_generated_option("caller", gld_gen.caller())?; - let source_file = convert_generated_option("source file", gld_gen.source_file())?; - let line = gld_gen.line(); - - Ok(GuestLogData { - message, - source, - level, - caller, - source_file, - line, - }) - } -} - -impl TryFrom<&GuestLogData> for Vec { - type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(value: &GuestLogData) -> Result> { - let mut builder = flatbuffers::FlatBufferBuilder::new(); - let message = builder.create_string(&value.message); - let source = builder.create_string(&value.source); - let caller = builder.create_string(&value.caller); - let source_file = builder.create_string(&value.source_file); - let level = FbLogLevel::from(&value.level); - - let guest_log_data_fb = FbGuestLogData::create( - &mut builder, - &FbGuestLogDataArgs { - message: Some(message), - source: Some(source), - level, - caller: Some(caller), - source_file: Some(source_file), - line: value.line, - }, - ); - builder.finish_size_prefixed(guest_log_data_fb, None); - let res = builder.finished_data().to_vec(); - - Ok(res) - } -} - -impl TryFrom for Vec { - type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(value: GuestLogData) -> Result> { - (&value).try_into() - } -} - -#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] -fn convert_generated_option(field_name: &str, opt: Option<&str>) -> Result { - opt.map(|s| s.to_string()) - .ok_or_else(|| anyhow!("Missing field: {}", field_name)) -} diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs index deec57070..442e07bde 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs @@ -14,15 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -use anyhow::{Error, Result, bail}; use log::Level; +use serde::{Deserialize, Serialize}; #[cfg(feature = "tracing")] use tracing::{Span, instrument}; -use crate::flatbuffers::hyperlight::generated::LogLevel as FbLogLevel; - #[repr(u8)] -#[derive(Copy, Clone, Eq, PartialEq, Debug)] +#[derive(Copy, Clone, Eq, PartialEq, Debug, Serialize, Deserialize)] pub enum LogLevel { Trace = 0, Debug = 1, @@ -48,40 +46,6 @@ impl From for LogLevel { } } -impl TryFrom<&FbLogLevel> for LogLevel { - type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(val: &FbLogLevel) -> Result { - match *val { - FbLogLevel::Trace => Ok(LogLevel::Trace), - FbLogLevel::Debug => Ok(LogLevel::Debug), - FbLogLevel::Information => Ok(LogLevel::Information), - FbLogLevel::Warning => Ok(LogLevel::Warning), - FbLogLevel::Error => Ok(LogLevel::Error), - FbLogLevel::Critical => Ok(LogLevel::Critical), - FbLogLevel::None => Ok(LogLevel::None), - _ => { - bail!("Unsupported Flatbuffers log level: {:?}", val); - } - } - } -} - -impl From<&LogLevel> for FbLogLevel { - #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] - fn from(val: &LogLevel) -> FbLogLevel { - match val { - LogLevel::Critical => FbLogLevel::Critical, - LogLevel::Debug => FbLogLevel::Debug, - LogLevel::Error => FbLogLevel::Error, - LogLevel::Information => FbLogLevel::Information, - LogLevel::None => FbLogLevel::None, - LogLevel::Trace => FbLogLevel::Trace, - LogLevel::Warning => FbLogLevel::Warning, - } - } -} - impl From<&LogLevel> for Level { // There is a test (sandbox::outb::tests::test_log_outb_log) which emits trace record as logs // which causes a panic when this function is instrumented as the logger is contained in refcell and diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/guest_trace_data.rs b/src/hyperlight_common/src/flatbuffer_wrappers/guest_trace_data.rs index b2006bf77..4ff26d119 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/guest_trace_data.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/guest_trace_data.rs @@ -21,27 +21,16 @@ limitations under the License. //! //! Schema definitions can be found in `src/schema/guest_trace_data.fbs`. -use alloc::string::{String, ToString}; +use alloc::string::String; use alloc::vec::Vec; -use anyhow::{Error, Result, anyhow}; -/// Estimate the serialized byte length for a size-prefixed `GuestEvent` buffer. -pub use estimate::estimate_event; -use flatbuffers::size_prefixed_root; - -use crate::flatbuffers::hyperlight::generated::{ - CloseSpanType as FbCloseSpanType, CloseSpanTypeArgs as FbCloseSpanTypeArgs, - EditSpanType as FbEditSpanType, EditSpanTypeArgs as FbEditSpanTypeArgs, - GuestEventEnvelopeType as FbGuestEventEnvelopeType, - GuestEventEnvelopeTypeArgs as FbGuestEventEnvelopeTypeArgs, GuestEventType as FbGuestEventType, - GuestStartType as FbGuestStartType, GuestStartTypeArgs as FbGuestStartTypeArgs, - KeyValue as FbKeyValue, KeyValueArgs as FbKeyValueArgs, LogEventType as FbLogEventType, - LogEventTypeArgs as FbLogEventTypeArgs, OpenSpanType as FbOpenSpanType, - OpenSpanTypeArgs as FbOpenSpanTypeArgs, -}; +use anyhow::{Error, Result}; +use serde::{Deserialize, Serialize}; + +use crate::flatbuffer_wrappers::util::{decode_rest, encode_extend, encoded_size}; /// Key-Value pair structure used in tracing spans/events -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct EventKeyValue { /// Key of the key-value pair pub key: String, @@ -49,56 +38,9 @@ pub struct EventKeyValue { pub value: String, } -impl From> for EventKeyValue { - fn from(value: FbKeyValue<'_>) -> Self { - let key = value.key().to_string(); - let value = value.value().to_string(); - - EventKeyValue { key, value } - } -} - -impl TryFrom<&[u8]> for EventKeyValue { - type Error = Error; - - fn try_from(value: &[u8]) -> Result { - let gld_gen = size_prefixed_root::(value) - .map_err(|e| anyhow!("Error while reading EventKeyValue: {:?}", e))?; - let key = gld_gen.key().to_string(); - let value = gld_gen.value().to_string(); - - Ok(EventKeyValue { key, value }) - } -} - -impl From<&EventKeyValue> for Vec { - fn from(value: &EventKeyValue) -> Self { - let mut builder = flatbuffers::FlatBufferBuilder::new(); - - let key_offset = builder.create_string(&value.key); - let value_offset = builder.create_string(&value.value); - - let kv_args = FbKeyValueArgs { - key: Some(key_offset), - value: Some(value_offset), - }; - - let kv_fb = FbKeyValue::create(&mut builder, &kv_args); - builder.finish_size_prefixed(kv_fb, None); - - builder.finished_data().to_vec() - } -} - -impl From for Vec { - fn from(value: EventKeyValue) -> Self { - Vec::from(&value) - } -} - /// Enum representing different types of guest events for tracing /// such as opening/closing spans and logging events. -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum GuestEvent { /// Event representing the opening of a new tracing span. OpenSpan { @@ -172,150 +114,18 @@ pub trait EventsDecoder { fn decode(&self, buffer: &[u8]) -> Result, Error>; } -impl TryFrom<&[u8]> for GuestEvent { - type Error = Error; - - fn try_from(value: &[u8]) -> Result { - let envelope = size_prefixed_root::(value) - .map_err(|e| anyhow!("Error while reading GuestTraceData: {:?}", e))?; - let event_type = envelope.event_type(); - - // Match on the event type to extract the appropriate event data - let event = match event_type { - FbGuestEventType::OpenSpan => { - // Extract OpenSpanType event data - let ost_fb = envelope - .event_as_open_span() - .ok_or_else(|| anyhow!("Failed to cast to OpenSpanType"))?; - - // Extract fields - let id = ost_fb.id(); - let parent = ost_fb.parent(); - let name = ost_fb.name().to_string(); - let target = ost_fb.target().to_string(); - let tsc = ost_fb.tsc(); - - // Extract key-value fields - let mut fields = Vec::new(); - if let Some(fb_fields) = ost_fb.fields() { - for j in 0..fb_fields.len() { - let kv: EventKeyValue = EventKeyValue::from(fb_fields.get(j)); - fields.push(kv); - } - } - - // Construct OpenSpan event - GuestEvent::OpenSpan { - id, - parent_id: parent, - name, - target, - tsc, - fields, - } - } - FbGuestEventType::CloseSpan => { - // Extract CloseSpanType event data - let cst_fb = envelope - .event_as_close_span() - .ok_or_else(|| anyhow!("Failed to cast to CloseSpanType"))?; - // Extract fields - let id = cst_fb.id(); - let tsc = cst_fb.tsc(); - - // Construct CloseSpan event - GuestEvent::CloseSpan { id, tsc } - } - FbGuestEventType::LogEvent => { - // Extract LogEventType event data - let le_fb = envelope - .event_as_log_event() - .ok_or_else(|| anyhow!("Failed to cast to LogEventType"))?; - - // Extract fields - let parent_id = le_fb.parent_id(); - let name = le_fb.name().to_string(); - let tsc = le_fb.tsc(); - - // Extract key-value fields - let mut fields = Vec::new(); - if let Some(fb_fields) = le_fb.fields() { - for j in 0..fb_fields.len() { - let kv: EventKeyValue = EventKeyValue::from(fb_fields.get(j)); - fields.push(kv); - } - } - - // Construct LogEvent - GuestEvent::LogEvent { - parent_id, - name, - tsc, - fields, - } - } - FbGuestEventType::EditSpan => { - let est_fb = envelope - .event_as_edit_span() - .ok_or_else(|| anyhow!("Failed to cast to EditSpanType"))?; - // Extract fields - let id = est_fb.id(); - let mut fields = Vec::new(); - if let Some(fb_fields) = est_fb.fields() { - for j in 0..fb_fields.len() { - let kv: EventKeyValue = EventKeyValue::from(fb_fields.get(j)); - fields.push(kv); - } - } - - // Construct EditSpan event - GuestEvent::EditSpan { id, fields } - } - FbGuestEventType::GuestStart => { - let gst_fb = envelope - .event_as_guest_start() - .ok_or_else(|| anyhow!("Failed to cast to GuestStartType"))?; - - // Extract fields - let tsc = gst_fb.tsc(); - - // Construct GuestStart event - GuestEvent::GuestStart { tsc } - } - - _ => { - return Err(anyhow!("Unknown GuestEventType={}", event_type.0)); - } - }; - - Ok(event) - } -} - pub struct EventsBatchDecoder; impl EventsDecoder for EventsBatchDecoder { fn decode(&self, data: &[u8]) -> Result, Error> { - let mut cursor = 0; let mut events = Vec::new(); - while data.len() - cursor >= 4 { - let size_bytes = &data[cursor..cursor + 4]; - // The size_bytes is in little-endian format and the while condition ensures there are - // at least 4 bytes to read. - let payload_size = u32::from_le_bytes(size_bytes.try_into()?) as usize; - let event_size = 4 + payload_size; - if data.len() - cursor < event_size { - return Err(anyhow!( - "The serialized buffer does not contain a full set of events", - )); - } + let mut data = data; - let event_slice = &data[cursor..cursor + event_size]; - let event = GuestEvent::try_from(event_slice)?; + while !data.is_empty() { + let (event, rest) = decode_rest::(data)?; events.push(event); - - cursor += event_size; + data = rest; } Ok(events) @@ -365,184 +175,9 @@ impl EventsEncoder for EventsBatchEncoderGeneric { // - If the estimate is accurate or slightly over, the builder uses the preallocated // space. // - If the estimate is too low, the FlatBuffer builder reallocates as needed. - let estimated_size = estimate::estimate_event(event); - let mut builder = flatbuffers::FlatBufferBuilder::with_capacity(estimated_size); - - // Serialize the event based on its type - let ev = match event { - GuestEvent::OpenSpan { - id, - parent_id, - name, - target, - tsc, - fields, - } => { - // Serialize strings - let name_offset = builder.create_string(name); - let target_offset = builder.create_string(target); - - // Serialize key-value fields - let mut field_offsets = Vec::new(); - for field in fields { - let field_offset: flatbuffers::WIPOffset = { - let key_offset = builder.create_string(&field.key); - let value_offset = builder.create_string(&field.value); - let kv_args = FbKeyValueArgs { - key: Some(key_offset), - value: Some(value_offset), - }; - FbKeyValue::create(&mut builder, &kv_args) - }; - field_offsets.push(field_offset); - } - - // Create fields vector - let fields_vector = if !field_offsets.is_empty() { - Some(builder.create_vector(&field_offsets)) - } else { - None - }; - - let ost_args = FbOpenSpanTypeArgs { - id: *id, - parent: *parent_id, - name: Some(name_offset), - target: Some(target_offset), - tsc: *tsc, - fields: fields_vector, - }; - - // Create the OpenSpanType FlatBuffer object - let ost_fb = FbOpenSpanType::create(&mut builder, &ost_args); - - // Create the GuestEventEnvelopeType - let guest_event_fb = FbGuestEventType::OpenSpan; - let envelope_args = FbGuestEventEnvelopeTypeArgs { - event_type: guest_event_fb, - event: Some(ost_fb.as_union_value()), - }; - - // Create the envelope using the union value - FbGuestEventEnvelopeType::create(&mut builder, &envelope_args) - } - GuestEvent::CloseSpan { id, tsc } => { - // Create CloseSpanType FlatBuffer object - let cst_args = FbCloseSpanTypeArgs { id: *id, tsc: *tsc }; - let cst_fb = FbCloseSpanType::create(&mut builder, &cst_args); - - // Create the GuestEventEnvelopeType - let guest_event_fb = FbGuestEventType::CloseSpan; - let envelope_args = FbGuestEventEnvelopeTypeArgs { - event_type: guest_event_fb, - event: Some(cst_fb.as_union_value()), - }; - // Create the envelope using the union value - FbGuestEventEnvelopeType::create(&mut builder, &envelope_args) - } - GuestEvent::LogEvent { - parent_id, - name, - tsc, - fields, - } => { - // Serialize strings - let name_offset = builder.create_string(name); - - // Serialize key-value fields - let mut field_offsets = Vec::new(); - for field in fields { - let field_offset: flatbuffers::WIPOffset = { - let key_offset = builder.create_string(&field.key); - let value_offset = builder.create_string(&field.value); - let kv_args = FbKeyValueArgs { - key: Some(key_offset), - value: Some(value_offset), - }; - FbKeyValue::create(&mut builder, &kv_args) - }; - field_offsets.push(field_offset); - } - - let fields_vector = if !field_offsets.is_empty() { - Some(builder.create_vector(&field_offsets)) - } else { - None - }; - - let le_args = FbLogEventTypeArgs { - parent_id: *parent_id, - name: Some(name_offset), - tsc: *tsc, - fields: fields_vector, - }; - - let le_fb = FbLogEventType::create(&mut builder, &le_args); - - // Create the GuestEventEnvelopeType - let guest_event_fb = FbGuestEventType::LogEvent; - let envelope_args = FbGuestEventEnvelopeTypeArgs { - event_type: guest_event_fb, - event: Some(le_fb.as_union_value()), - }; - // Create the envelope using the union value - FbGuestEventEnvelopeType::create(&mut builder, &envelope_args) - } - GuestEvent::EditSpan { id, fields } => { - // Serialize key-value fields - let mut field_offsets = Vec::new(); - for field in fields { - let field_offset: flatbuffers::WIPOffset = { - let key_offset = builder.create_string(&field.key); - let value_offset = builder.create_string(&field.value); - let kv_args = FbKeyValueArgs { - key: Some(key_offset), - value: Some(value_offset), - }; - FbKeyValue::create(&mut builder, &kv_args) - }; - field_offsets.push(field_offset); - } - - // Create fields vector - let fields_vector = if !field_offsets.is_empty() { - Some(builder.create_vector(&field_offsets)) - } else { - None - }; - - let est_args = FbEditSpanTypeArgs { - id: *id, - fields: fields_vector, - }; - - let es_fb = FbEditSpanType::create(&mut builder, &est_args); - - // Create the GuestEventEnvelopeType - let guest_event_fb = FbGuestEventType::EditSpan; - let envelope_args = FbGuestEventEnvelopeTypeArgs { - event_type: guest_event_fb, - event: Some(es_fb.as_union_value()), - }; - - FbGuestEventEnvelopeType::create(&mut builder, &envelope_args) - } - GuestEvent::GuestStart { tsc } => { - let gst_args = FbGuestStartTypeArgs { tsc: *tsc }; - let gs_fb = FbGuestStartType::create(&mut builder, &gst_args); - // Create the GuestEventEnvelopeType - let guest_event_fb = FbGuestEventType::GuestStart; - let envelope_args = FbGuestEventEnvelopeTypeArgs { - event_type: guest_event_fb, - event: Some(gs_fb.as_union_value()), - }; - - FbGuestEventEnvelopeType::create(&mut builder, &envelope_args) - } - }; - - builder.finish_size_prefixed(ev, None); - let serialized = builder.finished_data(); + let estimated_size = estimate_event(event); + let serialized = Vec::with_capacity(estimated_size); + let serialized = encode_extend(event, serialized).unwrap(); // Check if adding this event would exceed capacity if self.used_capacity + serialized.len() > self.capacity { @@ -551,7 +186,7 @@ impl EventsEncoder for EventsBatchEncoderGeneric { self.used_capacity = 0; } // Append serialized data to buffer - self.buffer.extend_from_slice(serialized); + self.buffer.extend_from_slice(&serialized); self.used_capacity += serialized.len(); } @@ -577,292 +212,16 @@ impl EventsEncoder for EventsBatchEncoderGeneric { } } -mod estimate { - use super::{EventKeyValue, GuestEvent}; - - const SIZE_PREFIX: usize = 4; - const ENVELOPE_TABLE_OVERHEAD: usize = 20; - /// Bytes needed for the data section of the `KeyValue` table (offset + slots). - const KV_TABLE_DATA_BYTES: usize = 12; - /// Vtables are deduplicated by the FlatBuffers builder; pay for it at most once. - const KV_VTABLE_BYTES: usize = 8; - const OPEN_TABLE_OVERHEAD: usize = 72; - const CLOSE_TABLE_OVERHEAD: usize = 32; - const LOG_TABLE_OVERHEAD: usize = 52; - const EDIT_TABLE_OVERHEAD: usize = 40; - const GUEST_START_TABLE_OVERHEAD: usize = 24; - - /// Round up to next multiple of 4. - fn pad4(x: usize) -> usize { - (4 - (x & 3)) & 3 - } - - /// Size of a FlatBuffers string object with `len` UTF-8 bytes. - fn size_str(len: usize) -> usize { - let size = 4 + len + 1; - size + pad4(size) - } - - fn size_kv_entry(k_len: usize, v_len: usize) -> usize { - KV_TABLE_DATA_BYTES + size_str(k_len) + size_str(v_len) - } - - fn size_kv_vec(fields: &[EventKeyValue]) -> usize { - if fields.is_empty() { - return 0; - } - - let head = 4 + 4 * fields.len(); - let entries = fields - .iter() - .map(|kv| size_kv_entry(kv.key.len(), kv.value.len())) - .sum::(); - - // The vtable for `KeyValue` tables is shared across entries, so only account for - // it once even if multiple fields are present. - head + pad4(head) + entries + KV_VTABLE_BYTES - } - - fn base_envelope() -> usize { - SIZE_PREFIX + ENVELOPE_TABLE_OVERHEAD - } - - fn open_span_size(name_len: usize, target_len: usize, fields: &[EventKeyValue]) -> usize { - OPEN_TABLE_OVERHEAD + size_str(name_len) + size_str(target_len) + size_kv_vec(fields) - } - - fn log_event_size(name_len: usize, fields: &[EventKeyValue]) -> usize { - LOG_TABLE_OVERHEAD + size_str(name_len) + size_kv_vec(fields) - } - - fn edit_span_size(fields: &[EventKeyValue]) -> usize { - EDIT_TABLE_OVERHEAD + size_kv_vec(fields) - } - - /// Estimate the serialized byte length for a size-prefixed `GuestEvent` buffer. - /// The estimate is designed to be an upper bound on the actual serialized size, - /// with some reasonable slack to account for FlatBuffers overhead. - /// The maximum slack is approximately 10% of the actual size or 128 bytes, - /// whichever is larger. - /// NOTE: This is only an estimate and may not be exact. - /// The estimation upper bound is not guaranteed to be strict, it has been - /// empirically verified to be reasonable in practice. - pub fn estimate_event(event: &GuestEvent) -> usize { - base_envelope() - + match event { - GuestEvent::OpenSpan { - name, - target, - fields, - .. - } => open_span_size(name.len(), target.len(), fields), - GuestEvent::CloseSpan { .. } => CLOSE_TABLE_OVERHEAD, - GuestEvent::LogEvent { name, fields, .. } => log_event_size(name.len(), fields), - GuestEvent::EditSpan { fields, .. } => edit_span_size(fields), - GuestEvent::GuestStart { .. } => GUEST_START_TABLE_OVERHEAD, - } - } - - #[cfg(test)] - mod tests { - use alloc::string::String; - use alloc::vec::Vec; - use alloc::{format, vec}; - - use super::estimate_event; - use crate::flatbuffer_wrappers::guest_trace_data::{ - EventKeyValue, EventsBatchEncoder, EventsEncoder, GuestEvent, - }; - - fn encoded_size(event: &GuestEvent) -> usize { - let mut encoder = EventsBatchEncoder::new(2048, |_| {}); - encoder.encode(event); - encoder.finish().len() - } - - fn assert_estimate_bounds(actual: usize, estimate: usize) { - assert!( - estimate >= actual, - "estimated size {} must be at least actual {}", - estimate, - actual, - ); - - let slack = (actual / 10).max(128); - let upper_bound = actual + slack; - assert!( - estimate <= upper_bound, - "estimated size {} exceeds reasonable bound {} for actual {}", - estimate, - upper_bound, - actual, - ); - } - - #[test] - fn test_estimate_open_span_reasonable() { - let event = GuestEvent::OpenSpan { - id: 1, - parent_id: None, - name: String::from("span"), - target: String::from("target"), - tsc: 10, - fields: vec![EventKeyValue { - key: String::from("k"), - value: String::from("v"), - }], - }; - - let estimate = estimate_event(&event); - let actual = encoded_size(&event); - assert_estimate_bounds(actual, estimate); - } - - #[test] - fn test_estimate_open_span_large_payload() { - let long_field_value = "v".repeat(4096); - let long_name = "span".repeat(256); - let event = GuestEvent::OpenSpan { - id: 42, - parent_id: Some(5), - name: long_name.clone(), - target: "target".repeat(256), - tsc: 1234, - fields: vec![EventKeyValue { - key: "key".repeat(64), - value: long_field_value, - }], - }; - - let estimate = estimate_event(&event); - let actual = encoded_size(&event); - assert_estimate_bounds(actual, estimate); - } - - #[test] - fn test_estimate_close_span_reasonable() { - let event = GuestEvent::CloseSpan { id: 7, tsc: 99 }; - let estimate = estimate_event(&event); - let actual = encoded_size(&event); - assert_estimate_bounds(actual, estimate); - } - - #[test] - fn test_estimate_log_event_reasonable() { - let event = GuestEvent::LogEvent { - parent_id: 5, - name: String::from("log"), - tsc: 55, - fields: vec![ - EventKeyValue { - key: String::from("kk"), - value: String::from("vv"), - }, - EventKeyValue { - key: String::from("m"), - value: String::from("n"), - }, - ], - }; - let estimate = estimate_event(&event); - let actual = encoded_size(&event); - assert_estimate_bounds(actual, estimate); - } - - #[test] - fn test_estimate_log_event_many_fields() { - let fields = (0..64) - .map(|i| EventKeyValue { - key: format!("k{}", i), - value: "value".repeat(i + 1), - }) - .collect::>(); - - let event = GuestEvent::LogEvent { - parent_id: 77, - name: "logname".repeat(64), - tsc: 9876, - fields, - }; - - let estimate = estimate_event(&event); - let actual = encoded_size(&event); - assert_estimate_bounds(actual, estimate); - } - - #[test] - fn test_estimate_edit_span_reasonable() { - let event = GuestEvent::EditSpan { - id: 9, - fields: vec![EventKeyValue { - key: String::from("field"), - value: String::from("value"), - }], - }; - let estimate = estimate_event(&event); - let actual = encoded_size(&event); - assert_estimate_bounds(actual, estimate); - } - - #[test] - fn test_estimate_guest_start_reasonable() { - let event = GuestEvent::GuestStart { tsc: 0 }; - let estimate = estimate_event(&event); - let actual = encoded_size(&event); - assert_estimate_bounds(actual, estimate); - } - - #[test] - fn test_estimate_guest_start_corner_cases() { - let very_large = GuestEvent::GuestStart { tsc: u64::MAX }; - let zero = GuestEvent::GuestStart { tsc: 0 }; - - for event in [&very_large, &zero] { - let estimate = estimate_event(event); - let actual = encoded_size(event); - assert_estimate_bounds(actual, estimate); - } - } - - #[test] - fn test_estimate_edit_span_empty_fields() { - let event = GuestEvent::EditSpan { - id: 999, - fields: Vec::new(), - }; - - let estimate = estimate_event(&event); - let actual = encoded_size(&event); - assert_estimate_bounds(actual, estimate); - } - - #[test] - fn test_estimate_edit_span_large() { - let fields = (0..32) - .map(|i| EventKeyValue { - key: format!("long_key_{}", i).repeat(4), - value: "Z".repeat(8192), - }) - .collect::>(); - - let event = GuestEvent::EditSpan { id: 10, fields }; - let estimate = estimate_event(&event); - let actual = encoded_size(&event); - assert_estimate_bounds(actual, estimate); - } - } +pub fn estimate_event(event: &GuestEvent) -> usize { + encoded_size(event).unwrap() } #[cfg(test)] mod tests { - use flatbuffers::FlatBufferBuilder; + use alloc::string::ToString; use super::*; - use crate::flatbuffers::hyperlight::generated::{ - GuestEventEnvelopeType as FbGuestEventEnvelopeType, - GuestEventEnvelopeTypeArgs as FbGuestEventEnvelopeTypeArgs, - GuestEventType as FbGuestEventType, - }; + use crate::flatbuffer_wrappers::util::{decode, encode}; /// Utility function to check an original GuestTraceData against a deserialized one fn check_fb_guest_trace_data(orig: &[GuestEvent], deserialized: &[GuestEvent]) { @@ -959,9 +318,8 @@ mod tests { value: "test_value".to_string(), }; - let serialized: Vec = Vec::from(&kv); - let deserialized: EventKeyValue = - EventKeyValue::try_from(serialized.as_slice()).expect("Deserialization failed"); + let serialized = encode(&kv).expect("Serialization failed"); + let deserialized: EventKeyValue = decode(&serialized).expect("Deserialization failed"); assert_eq!(kv.key, deserialized.key); assert_eq!(kv.value, deserialized.value); @@ -1289,49 +647,15 @@ mod tests { "serialized buffer must be non-empty" ); - let err = EventsBatchDecoder {} + EventsBatchDecoder {} .decode(&truncated) .expect_err("Decoder must fail when payload is truncated"); - assert!( - err.to_string() - .contains("The serialized buffer does not contain a full set of events"), - "unexpected error: {}", - err, - ); - } - - #[test] - fn test_guest_event_try_from_errors_on_missing_union_payload() { - let mut builder = FlatBufferBuilder::new(); - let envelope = FbGuestEventEnvelopeType::create( - &mut builder, - &FbGuestEventEnvelopeTypeArgs { - event_type: FbGuestEventType::OpenSpan, - event: None, - }, - ); - builder.finish_size_prefixed(envelope, None); - let serialized = builder.finished_data(); - - let err = GuestEvent::try_from(serialized) - .expect_err("Deserialization must fail when union payload is missing"); - assert!( - err.to_string().contains("InconsistentUnion"), - "unexpected error: {}", - err, - ); } #[test] fn test_event_key_value_try_from_rejects_short_buffer() { - let buffer = [0x00_u8, 0x01, 0x02]; - let err = EventKeyValue::try_from(buffer.as_slice()) + let buffer = [0x00_u8, 0x01]; + decode::(&buffer) .expect_err("Deserialization must fail for undersized buffer"); - assert!( - err.to_string() - .contains("Error while reading EventKeyValue"), - "unexpected error: {}", - err, - ); } } diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs index edd447f4d..ec25f9076 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs @@ -14,22 +14,18 @@ See the License for the specific language governing permissions and limitations under the License. */ -use alloc::string::{String, ToString}; +use alloc::string::String; use alloc::vec::Vec; -use anyhow::{Error, Result, anyhow}; -use flatbuffers::{FlatBufferBuilder, WIPOffset}; +use anyhow::{Result, anyhow}; +use serde::{Deserialize, Serialize}; #[cfg(feature = "tracing")] use tracing::{Span, instrument}; use super::function_types::{ParameterType, ReturnType}; -use crate::flatbuffers::hyperlight::generated::{ - HostFunctionDefinition as FbHostFunctionDefinition, - HostFunctionDefinitionArgs as FbHostFunctionDefinitionArgs, ParameterType as FbParameterType, -}; /// The definition of a function exposed from the host to the guest -#[derive(Debug, Default, Clone, PartialEq, Eq)] +#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct HostFunctionDefinition { /// The function name pub function_name: String, @@ -54,40 +50,6 @@ impl HostFunctionDefinition { } } - /// Convert this `HostFunctionDefinition` into a `WIPOffset`. - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - pub(crate) fn convert_to_flatbuffer_def<'a>( - &self, - builder: &mut FlatBufferBuilder<'a>, - ) -> Result>> { - let host_function_name = builder.create_string(&self.function_name); - let return_value_type = self.return_type.into(); - let vec_parameters = match &self.parameter_types { - Some(vec_pvt) => { - let num_items = vec_pvt.len(); - let mut parameters: Vec = Vec::with_capacity(num_items); - for pvt in vec_pvt { - let fb_pvt = pvt.clone().into(); - parameters.push(fb_pvt); - } - Some(builder.create_vector(¶meters)) - } - None => None, - }; - - let fb_host_function_definition: WIPOffset = - FbHostFunctionDefinition::create( - builder, - &FbHostFunctionDefinitionArgs { - function_name: Some(host_function_name), - return_type: return_value_type, - parameters: vec_parameters, - }, - ); - - Ok(fb_host_function_definition) - } - /// Verify that the function call has the correct parameter types. #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] pub fn verify_equal_parameter_types( @@ -104,57 +66,3 @@ impl HostFunctionDefinition { Ok(()) } } - -impl TryFrom<&FbHostFunctionDefinition<'_>> for HostFunctionDefinition { - type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(value: &FbHostFunctionDefinition) -> Result { - let function_name = value.function_name().to_string(); - let return_type = value.return_type().try_into().map_err(|_| { - anyhow!( - "Failed to convert return type for function {}", - function_name - ) - })?; - let parameter_types = match value.parameters() { - Some(pvt) => { - let len = pvt.len(); - let mut pv: Vec = Vec::with_capacity(len); - for fb_pvt in pvt { - let pvt: ParameterType = fb_pvt.try_into().map_err(|_| { - anyhow!( - "Failed to convert parameter type for function {}", - function_name - ) - })?; - pv.push(pvt); - } - Some(pv) - } - None => None, - }; - - Ok(Self::new(function_name, parameter_types, return_type)) - } -} - -impl TryFrom<&[u8]> for HostFunctionDefinition { - type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(value: &[u8]) -> Result { - let fb_host_function_definition = flatbuffers::root::>(value) - .map_err(|e| anyhow!("Error while reading HostFunctionDefinition: {:?}", e))?; - Self::try_from(&fb_host_function_definition) - } -} - -impl TryFrom<&HostFunctionDefinition> for Vec { - type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(hfd: &HostFunctionDefinition) -> Result> { - let mut builder = flatbuffers::FlatBufferBuilder::new(); - let host_function_definition = hfd.convert_to_flatbuffer_def(&mut builder)?; - builder.finish_size_prefixed(host_function_definition, None); - Ok(builder.finished_data().to_vec()) - } -} diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs index 2c18a584b..f93f97089 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs @@ -16,87 +16,13 @@ limitations under the License. use alloc::vec::Vec; -use anyhow::{Error, Result}; -use flatbuffers::{WIPOffset, size_prefixed_root}; -#[cfg(feature = "tracing")] -use tracing::{Span, instrument}; +use serde::{Deserialize, Serialize}; use super::host_function_definition::HostFunctionDefinition; -use crate::flatbuffers::hyperlight::generated::{ - HostFunctionDefinition as FbHostFunctionDefinition, - HostFunctionDetails as FbHostFunctionDetails, - HostFunctionDetailsArgs as FbHostFunctionDetailsArgs, -}; /// `HostFunctionDetails` represents the set of functions that the host exposes to the guest. -#[derive(Debug, Default, Clone)] +#[derive(Debug, Default, Clone, Serialize, Deserialize)] pub struct HostFunctionDetails { /// The host functions. pub host_functions: Option>, } - -impl TryFrom<&[u8]> for HostFunctionDetails { - type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(value: &[u8]) -> Result { - let host_function_details_fb = size_prefixed_root::(value) - .map_err(|e| anyhow::anyhow!("Error while reading HostFunctionDetails: {:?}", e))?; - - let host_function_definitions = match host_function_details_fb.functions() { - Some(hfd) => { - let len = hfd.len(); - let mut vec_hfd: Vec = Vec::with_capacity(len); - for i in 0..len { - let fb_host_function_definition = hfd.get(i); - let hfdef = HostFunctionDefinition::try_from(&fb_host_function_definition)?; - vec_hfd.push(hfdef); - } - - Some(vec_hfd) - } - - None => None, - }; - - Ok(Self { - host_functions: host_function_definitions, - }) - } -} - -impl TryFrom<&HostFunctionDetails> for Vec { - type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] - fn try_from(value: &HostFunctionDetails) -> Result> { - let mut builder = flatbuffers::FlatBufferBuilder::new(); - let vec_host_function_definitions = match &value.host_functions { - Some(vec_hfd) => { - let num_items = vec_hfd.len(); - let mut host_function_definitions: Vec> = - Vec::with_capacity(num_items); - - for hfd in vec_hfd { - let host_function_definition = hfd.convert_to_flatbuffer_def(&mut builder)?; - host_function_definitions.push(host_function_definition); - } - - Some(host_function_definitions) - } - None => None, - }; - - let fb_host_function_definitions = - vec_host_function_definitions.map(|v| builder.create_vector(&v)); - - let host_function_details = FbHostFunctionDetails::create( - &mut builder, - &FbHostFunctionDetailsArgs { - functions: fb_host_function_definitions, - }, - ); - builder.finish_size_prefixed(host_function_details, None); - let res = builder.finished_data().to_vec(); - - Ok(res) - } -} diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/util.rs b/src/hyperlight_common/src/flatbuffer_wrappers/util.rs index 2ee32c9a3..3b3b186d4 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/util.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/util.rs @@ -16,220 +16,43 @@ limitations under the License. use alloc::vec::Vec; -use flatbuffers::FlatBufferBuilder; - -use crate::flatbuffer_wrappers::function_types::ParameterValue; -use crate::flatbuffers::hyperlight::generated::{ - FunctionCallResult as FbFunctionCallResult, FunctionCallResultArgs as FbFunctionCallResultArgs, - FunctionCallResultType as FbFunctionCallResultType, ReturnValue as FbReturnValue, - ReturnValueBox, ReturnValueBoxArgs, hlbool as Fbhlbool, hlboolArgs as FbhlboolArgs, - hldouble as Fbhldouble, hldoubleArgs as FbhldoubleArgs, hlfloat as Fbhlfloat, - hlfloatArgs as FbhlfloatArgs, hlint as Fbhlint, hlintArgs as FbhlintArgs, hllong as Fbhllong, - hllongArgs as FbhllongArgs, hlsizeprefixedbuffer as Fbhlsizeprefixedbuffer, - hlsizeprefixedbufferArgs as FbhlsizeprefixedbufferArgs, hlstring as Fbhlstring, - hlstringArgs as FbhlstringArgs, hluint as Fbhluint, hluintArgs as FbhluintArgs, - hlulong as Fbhlulong, hlulongArgs as FbhlulongArgs, hlvoid as Fbhlvoid, - hlvoidArgs as FbhlvoidArgs, -}; +pub use serde::{Deserialize, Serialize}; -/// Flatbuffer-encodes the given value -pub fn get_flatbuffer_result(val: T) -> Vec { - let mut builder = FlatBufferBuilder::new(); - let res = T::serialize(&val, &mut builder); - let result_offset = FbFunctionCallResult::create(&mut builder, &res); - - builder.finish_size_prefixed(result_offset, None); - - builder.finished_data().to_vec() -} +use crate::flatbuffer_wrappers::function_types::{FunctionCallResult, ParameterValue}; +use crate::func::ReturnValue; -pub trait FlatbufferSerializable { - fn serialize(&self, builder: &mut FlatBufferBuilder) -> FbFunctionCallResultArgs; -} - -// Implementations for basic types below - -impl FlatbufferSerializable for () { - fn serialize(&self, builder: &mut FlatBufferBuilder) -> FbFunctionCallResultArgs { - let void_off = Fbhlvoid::create(builder, &FbhlvoidArgs {}); - let rv_box = ReturnValueBox::create( - builder, - &ReturnValueBoxArgs { - value_type: FbReturnValue::hlvoid, - value: Some(void_off.as_union_value()), - }, - ); - FbFunctionCallResultArgs { - result_type: FbFunctionCallResultType::ReturnValueBox, - result: Some(rv_box.as_union_value()), - } - } -} - -impl FlatbufferSerializable for &str { - fn serialize(&self, builder: &mut FlatBufferBuilder) -> FbFunctionCallResultArgs { - let string_offset = builder.create_string(self); - let str_off = Fbhlstring::create( - builder, - &FbhlstringArgs { - value: Some(string_offset), - }, - ); - let rv_box = ReturnValueBox::create( - builder, - &ReturnValueBoxArgs { - value_type: FbReturnValue::hlstring, - value: Some(str_off.as_union_value()), - }, - ); - FbFunctionCallResultArgs { - result_type: FbFunctionCallResultType::ReturnValueBox, - result: Some(rv_box.as_union_value()), - } - } -} - -impl FlatbufferSerializable for &[u8] { - fn serialize(&self, builder: &mut FlatBufferBuilder) -> FbFunctionCallResultArgs { - let vec_off = builder.create_vector(self); - let buf_off = Fbhlsizeprefixedbuffer::create( - builder, - &FbhlsizeprefixedbufferArgs { - size: self.len() as i32, - value: Some(vec_off), - }, - ); - let rv_box = ReturnValueBox::create( - builder, - &ReturnValueBoxArgs { - value_type: FbReturnValue::hlsizeprefixedbuffer, - value: Some(buf_off.as_union_value()), - }, - ); - FbFunctionCallResultArgs { - result_type: FbFunctionCallResultType::ReturnValueBox, - result: Some(rv_box.as_union_value()), - } - } -} - -impl FlatbufferSerializable for f32 { - fn serialize(&self, builder: &mut FlatBufferBuilder) -> FbFunctionCallResultArgs { - let off = Fbhlfloat::create(builder, &FbhlfloatArgs { value: *self }); - let rv_box = ReturnValueBox::create( - builder, - &ReturnValueBoxArgs { - value_type: FbReturnValue::hlfloat, - value: Some(off.as_union_value()), - }, - ); - FbFunctionCallResultArgs { - result_type: FbFunctionCallResultType::ReturnValueBox, - result: Some(rv_box.as_union_value()), - } - } +/// Flatbuffer-encodes the given value +pub fn get_flatbuffer_result>(val: T) -> Vec { + let result = FunctionCallResult::new(Ok(val.into())); + encode(&result).unwrap() } -impl FlatbufferSerializable for f64 { - fn serialize(&self, builder: &mut FlatBufferBuilder) -> FbFunctionCallResultArgs { - let off = Fbhldouble::create(builder, &FbhldoubleArgs { value: *self }); - let rv_box = ReturnValueBox::create( - builder, - &ReturnValueBoxArgs { - value_type: FbReturnValue::hldouble, - value: Some(off.as_union_value()), - }, - ); - FbFunctionCallResultArgs { - result_type: FbFunctionCallResultType::ReturnValueBox, - result: Some(rv_box.as_union_value()), - } - } +pub fn encode(value: &impl Serialize) -> anyhow::Result> { + Ok(postcard::to_allocvec(value)?) } -impl FlatbufferSerializable for i32 { - fn serialize(&self, builder: &mut FlatBufferBuilder) -> FbFunctionCallResultArgs { - let off = Fbhlint::create(builder, &FbhlintArgs { value: *self }); - let rv_box = ReturnValueBox::create( - builder, - &ReturnValueBoxArgs { - value_type: FbReturnValue::hlint, - value: Some(off.as_union_value()), - }, - ); - FbFunctionCallResultArgs { - result_type: FbFunctionCallResultType::ReturnValueBox, - result: Some(rv_box.as_union_value()), - } - } +pub fn decode<'de, T: Deserialize<'de>>(buf: &'de [u8]) -> anyhow::Result { + Ok(postcard::from_bytes(buf)?) } -impl FlatbufferSerializable for i64 { - fn serialize(&self, builder: &mut FlatBufferBuilder) -> FbFunctionCallResultArgs { - let off = Fbhllong::create(builder, &FbhllongArgs { value: *self }); - let rv_box = ReturnValueBox::create( - builder, - &ReturnValueBoxArgs { - value_type: FbReturnValue::hllong, - value: Some(off.as_union_value()), - }, - ); - FbFunctionCallResultArgs { - result_type: FbFunctionCallResultType::ReturnValueBox, - result: Some(rv_box.as_union_value()), - } - } +pub fn decode_rest<'de, T: Deserialize<'de>>(buf: &'de [u8]) -> anyhow::Result<(T, &'de [u8])> { + Ok(postcard::take_from_bytes(buf)?) } -impl FlatbufferSerializable for u32 { - fn serialize(&self, builder: &mut FlatBufferBuilder) -> FbFunctionCallResultArgs { - let off = Fbhluint::create(builder, &FbhluintArgs { value: *self }); - let rv_box = ReturnValueBox::create( - builder, - &ReturnValueBoxArgs { - value_type: FbReturnValue::hluint, - value: Some(off.as_union_value()), - }, - ); - FbFunctionCallResultArgs { - result_type: FbFunctionCallResultType::ReturnValueBox, - result: Some(rv_box.as_union_value()), - } - } +pub fn encoded_size(value: &impl Serialize) -> anyhow::Result { + let storage = postcard::ser_flavors::Size::default(); + Ok(postcard::serialize_with_flavor(value, storage)?) } -impl FlatbufferSerializable for u64 { - fn serialize(&self, builder: &mut FlatBufferBuilder) -> FbFunctionCallResultArgs { - let off = Fbhlulong::create(builder, &FbhlulongArgs { value: *self }); - let rv_box = ReturnValueBox::create( - builder, - &ReturnValueBoxArgs { - value_type: FbReturnValue::hlulong, - value: Some(off.as_union_value()), - }, - ); - FbFunctionCallResultArgs { - result_type: FbFunctionCallResultType::ReturnValueBox, - result: Some(rv_box.as_union_value()), - } - } +pub fn encode_in<'a>(value: &impl Serialize, slice: &'a mut [u8]) -> anyhow::Result<&'a mut [u8]> { + Ok(postcard::to_slice(value, slice)?) } -impl FlatbufferSerializable for bool { - fn serialize(&self, builder: &mut FlatBufferBuilder) -> FbFunctionCallResultArgs { - let off = Fbhlbool::create(builder, &FbhlboolArgs { value: *self }); - let rv_box = ReturnValueBox::create( - builder, - &ReturnValueBoxArgs { - value_type: FbReturnValue::hlbool, - value: Some(off.as_union_value()), - }, - ); - FbFunctionCallResultArgs { - result_type: FbFunctionCallResultType::ReturnValueBox, - result: Some(rv_box.as_union_value()), - } - } +pub fn encode_extend>( + value: &impl Serialize, + writer: W, +) -> anyhow::Result { + Ok(postcard::to_extend(value, writer)?) } /// Estimates the required buffer capacity for encoding a FunctionCall with the given parameters. @@ -246,27 +69,52 @@ impl FlatbufferSerializable for bool { /// on https://flatbuffers.dev/internals/ and https://github.com/dvidelabs/flatcc/blob/f064cefb2034d1e7407407ce32a6085c322212a7/doc/binary-format.md#flatbuffers-binary-format #[inline] // allow cross-crate inlining (for hyperlight-host calls) pub fn estimate_flatbuffer_capacity(function_name: &str, args: &[ParameterValue]) -> usize { - let mut estimated_capacity = 20; - - // Function name overhead - estimated_capacity += function_name.len() + 12; - - // Parameters vector overhead - estimated_capacity += 12 + args.len() * 6; - - // Per-parameter overhead - for arg in args { - estimated_capacity += 16; // Base parameter structure - estimated_capacity += match arg { - ParameterValue::String(s) => s.len() + 20, - ParameterValue::VecBytes(v) => v.len() + 20, - ParameterValue::Int(_) | ParameterValue::UInt(_) => 16, - ParameterValue::Long(_) | ParameterValue::ULong(_) => 20, - ParameterValue::Float(_) => 16, - ParameterValue::Double(_) => 20, - ParameterValue::Bool(_) => 12, - }; + // A tuple with the same data as a FunctionCall to estimate size + // we use this tuple instead of FunctionCall directly to avoid having to clone + // function_name and args into a FunctionCall struct + let dummy = ( + function_name, + Some(args), + crate::flatbuffer_wrappers::function_call::FunctionCallType::Guest, + crate::flatbuffer_wrappers::function_types::ReturnType::Void, + ); + + let estimated_capacity = encoded_size(&dummy).unwrap(); + + /* + #[cfg(test)] + { + let mut old_estimated_capacity = 20; + + // Function name overhead + old_estimated_capacity += function_name.len() + 12; + + // Parameters vector overhead + old_estimated_capacity += 12 + args.len() * 6; + + // Per-parameter overhead + for arg in args { + old_estimated_capacity += 16; // Base parameter structure + old_estimated_capacity += match arg { + ParameterValue::String(s) => s.len() + 20, + ParameterValue::VecBytes(v) => v.len() + 20, + ParameterValue::Int(_) | ParameterValue::UInt(_) => 16, + ParameterValue::Long(_) | ParameterValue::ULong(_) => 20, + ParameterValue::Float(_) => 16, + ParameterValue::Double(_) => 20, + ParameterValue::Bool(_) => 12, + }; + } + + use std::io::Write; + let _ = write!( + std::io::stdout(), + "Estimated capacity: {}, Old estimated capacity: {}\n", + estimated_capacity, + old_estimated_capacity + ); } + */ // match how vec grows estimated_capacity.next_power_of_two() @@ -297,10 +145,9 @@ mod tests { call_type.clone(), return_type, ); - // Important that this FlatBufferBuilder is created with capacity 0 so it grows to its needed capacity - let mut builder = FlatBufferBuilder::new(); - let _buffer = fc.encode(&mut builder); - let actual = builder.collapse().0.capacity(); + + let encoded = encode(&fc).unwrap(); + let actual = encoded.capacity(); let lower_bound = (actual as f64 * 0.75) as usize; let upper_bound = (actual as f64 * 1.25) as usize; From c5e56303f44b048338c2d26bc7a19594fd690d3b Mon Sep 17 00:00:00 2001 From: Jorge Prendes Date: Thu, 8 Jan 2026 12:38:30 +0000 Subject: [PATCH 2/5] remove flatbuffers from hyperlight-common Signed-off-by: Jorge Prendes --- Cargo.lock | 1 - src/hyperlight_common/Cargo.toml | 1 - .../generated/close_span_type_generated.rs | 131 ----- .../generated/edit_span_type_generated.rs | 148 ------ .../generated/error_code_generated.rs | 171 ------- .../generated/function_call_generated.rs | 239 ---------- .../function_call_result_generated.rs | 223 --------- .../function_call_result_type_generated.rs | 110 ----- .../generated/function_call_type_generated.rs | 109 ----- .../generated/guest_error_generated.rs | 141 ------ .../guest_event_envelope_type_generated.rs | 312 ------------ .../generated/guest_event_generated.rs | 249 ---------- .../generated/guest_event_type_generated.rs | 126 ----- .../guest_event_union_type_generated.rs | 126 ----- .../generated/guest_log_data_generated.rs | 237 --------- .../generated/guest_start_type_generated.rs | 115 ----- .../hyperlight/generated/hlbool_generated.rs | 113 ----- .../generated/hldouble_generated.rs | 109 ----- .../hyperlight/generated/hlfloat_generated.rs | 109 ----- .../hyperlight/generated/hlint_generated.rs | 109 ----- .../hyperlight/generated/hllong_generated.rs | 109 ----- .../hlsizeprefixedbuffer_generated.rs | 148 ------ .../generated/hlstring_generated.rs | 115 ----- .../hyperlight/generated/hluint_generated.rs | 109 ----- .../hyperlight/generated/hlulong_generated.rs | 109 ----- .../generated/hlvecbytes_generated.rs | 124 ----- .../hyperlight/generated/hlvoid_generated.rs | 89 ---- .../host_function_definition_generated.rs | 204 -------- .../host_function_details_generated.rs | 134 ------ .../generated/key_value_generated.rs | 144 ------ .../generated/log_event_type_generated.rs | 195 -------- .../generated/log_level_generated.rs | 129 ----- .../generated/open_span_type_generated.rs | 235 --------- .../generated/parameter_generated.rs | 420 ---------------- .../generated/parameter_type_generated.rs | 137 ------ .../generated/parameter_value_generated.rs | 142 ------ .../generated/return_type_generated.rs | 141 ------ .../generated/return_value_box_generated.rs | 451 ------------------ .../generated/return_value_generated.rs | 146 ------ src/hyperlight_common/src/flatbuffers/mod.rs | 78 --- src/hyperlight_common/src/lib.rs | 5 +- 41 files changed, 1 insertion(+), 6242 deletions(-) delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/close_span_type_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/edit_span_type_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/error_code_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_result_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_result_type_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_type_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_error_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_envelope_type_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_type_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_union_type_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_log_data_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_start_type_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlbool_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/hldouble_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlfloat_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlint_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/hllong_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlsizeprefixedbuffer_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlstring_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/hluint_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlulong_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvecbytes_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvoid_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_definition_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_details_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/key_value_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/log_event_type_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/log_level_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/open_span_type_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_type_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_value_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_type_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_value_box_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_value_generated.rs delete mode 100644 src/hyperlight_common/src/flatbuffers/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 1e5156e22..f3fe1f57f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1392,7 +1392,6 @@ version = "0.12.0" dependencies = [ "anyhow", "arbitrary", - "flatbuffers", "log", "postcard", "serde", diff --git a/src/hyperlight_common/Cargo.toml b/src/hyperlight_common/Cargo.toml index 637d75600..64aa773a9 100644 --- a/src/hyperlight_common/Cargo.toml +++ b/src/hyperlight_common/Cargo.toml @@ -15,7 +15,6 @@ Hyperlight's components common to host and guest. workspace = true [dependencies] -flatbuffers = { version = "25.12.19", default-features = false } postcard = { version = "1.1.3", default-features = false, features = ["alloc"] } serde = { version = "1.0.228", default-features = false, features = ["derive", "alloc"] } anyhow = { version = "1.0.100", default-features = false } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/close_span_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/close_span_type_generated.rs deleted file mode 100644 index c88f61c63..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/close_span_type_generated.rs +++ /dev/null @@ -1,131 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum CloseSpanTypeOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct CloseSpanType<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for CloseSpanType<'a> { - type Inner = CloseSpanType<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> CloseSpanType<'a> { - pub const VT_ID: flatbuffers::VOffsetT = 4; - pub const VT_TSC: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - CloseSpanType { _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 CloseSpanTypeArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = CloseSpanTypeBuilder::new(_fbb); - builder.add_tsc(args.tsc); - builder.add_id(args.id); - builder.finish() - } - - #[inline] - pub fn id(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(CloseSpanType::VT_ID, Some(0)).unwrap() } - } - #[inline] - pub fn tsc(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(CloseSpanType::VT_TSC, Some(0)) - .unwrap() - } - } -} - -impl flatbuffers::Verifiable for CloseSpanType<'_> { - #[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::("tsc", Self::VT_TSC, false)? - .finish(); - Ok(()) - } -} -pub struct CloseSpanTypeArgs { - pub id: u64, - pub tsc: u64, -} -impl<'a> Default for CloseSpanTypeArgs { - #[inline] - fn default() -> Self { - CloseSpanTypeArgs { id: 0, tsc: 0 } - } -} - -pub struct CloseSpanTypeBuilder<'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> CloseSpanTypeBuilder<'a, 'b, A> { - #[inline] - pub fn add_id(&mut self, id: u64) { - self.fbb_.push_slot::(CloseSpanType::VT_ID, id, 0); - } - #[inline] - pub fn add_tsc(&mut self, tsc: u64) { - self.fbb_.push_slot::(CloseSpanType::VT_TSC, tsc, 0); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> CloseSpanTypeBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - CloseSpanTypeBuilder { - 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 CloseSpanType<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("CloseSpanType"); - ds.field("id", &self.id()); - ds.field("tsc", &self.tsc()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/edit_span_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/edit_span_type_generated.rs deleted file mode 100644 index 47e5b0bd8..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/edit_span_type_generated.rs +++ /dev/null @@ -1,148 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum EditSpanTypeOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct EditSpanType<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for EditSpanType<'a> { - type Inner = EditSpanType<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> EditSpanType<'a> { - pub const VT_ID: flatbuffers::VOffsetT = 4; - pub const VT_FIELDS: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - EditSpanType { _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 EditSpanTypeArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = EditSpanTypeBuilder::new(_fbb); - builder.add_id(args.id); - if let Some(x) = args.fields { - builder.add_fields(x); - } - builder.finish() - } - - #[inline] - pub fn id(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(EditSpanType::VT_ID, Some(0)).unwrap() } - } - #[inline] - pub fn fields( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(EditSpanType::VT_FIELDS, None) - } - } -} - -impl flatbuffers::Verifiable for EditSpanType<'_> { - #[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::>, - >>("fields", Self::VT_FIELDS, false)? - .finish(); - Ok(()) - } -} -pub struct EditSpanTypeArgs<'a> { - pub id: u64, - pub fields: Option< - flatbuffers::WIPOffset>>>, - >, -} -impl<'a> Default for EditSpanTypeArgs<'a> { - #[inline] - fn default() -> Self { - EditSpanTypeArgs { - id: 0, - fields: None, - } - } -} - -pub struct EditSpanTypeBuilder<'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> EditSpanTypeBuilder<'a, 'b, A> { - #[inline] - pub fn add_id(&mut self, id: u64) { - self.fbb_.push_slot::(EditSpanType::VT_ID, id, 0); - } - #[inline] - pub fn add_fields( - &mut self, - fields: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(EditSpanType::VT_FIELDS, fields); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> EditSpanTypeBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - EditSpanTypeBuilder { - 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 EditSpanType<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("EditSpanType"); - ds.field("id", &self.id()); - ds.field("fields", &self.fields()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/error_code_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/error_code_generated.rs deleted file mode 100644 index b299358e3..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/error_code_generated.rs +++ /dev/null @@ -1,171 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MIN_ERROR_CODE: u64 = 0; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MAX_ERROR_CODE: u64 = 17; -#[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_ERROR_CODE: [ErrorCode; 17] = [ - ErrorCode::NoError, - ErrorCode::UnsupportedParameterType, - ErrorCode::GuestFunctionNameNotProvided, - ErrorCode::GuestFunctionNotFound, - ErrorCode::GuestFunctionIncorrecNoOfParameters, - ErrorCode::GispatchFunctionPointerNotSet, - ErrorCode::OutbError, - ErrorCode::UnknownError, - ErrorCode::StackOverflow, - ErrorCode::GsCheckFailed, - ErrorCode::TooManyGuestFunctions, - ErrorCode::FailureInDlmalloc, - ErrorCode::MallocFailed, - ErrorCode::GuestFunctionParameterTypeMismatch, - ErrorCode::GuestError, - ErrorCode::ArrayLengthParamIsMissing, - ErrorCode::HostError, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct ErrorCode(pub u64); -#[allow(non_upper_case_globals)] -impl ErrorCode { - pub const NoError: Self = Self(0); - pub const UnsupportedParameterType: Self = Self(2); - pub const GuestFunctionNameNotProvided: Self = Self(3); - pub const GuestFunctionNotFound: Self = Self(4); - pub const GuestFunctionIncorrecNoOfParameters: Self = Self(5); - pub const GispatchFunctionPointerNotSet: Self = Self(6); - pub const OutbError: Self = Self(7); - pub const UnknownError: Self = Self(8); - pub const StackOverflow: Self = Self(9); - pub const GsCheckFailed: Self = Self(10); - pub const TooManyGuestFunctions: Self = Self(11); - pub const FailureInDlmalloc: Self = Self(12); - pub const MallocFailed: Self = Self(13); - pub const GuestFunctionParameterTypeMismatch: Self = Self(14); - pub const GuestError: Self = Self(15); - pub const ArrayLengthParamIsMissing: Self = Self(16); - pub const HostError: Self = Self(17); - - pub const ENUM_MIN: u64 = 0; - pub const ENUM_MAX: u64 = 17; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::NoError, - Self::UnsupportedParameterType, - Self::GuestFunctionNameNotProvided, - Self::GuestFunctionNotFound, - Self::GuestFunctionIncorrecNoOfParameters, - Self::GispatchFunctionPointerNotSet, - Self::OutbError, - Self::UnknownError, - Self::StackOverflow, - Self::GsCheckFailed, - Self::TooManyGuestFunctions, - Self::FailureInDlmalloc, - Self::MallocFailed, - Self::GuestFunctionParameterTypeMismatch, - Self::GuestError, - Self::ArrayLengthParamIsMissing, - Self::HostError, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::NoError => Some("NoError"), - Self::UnsupportedParameterType => Some("UnsupportedParameterType"), - Self::GuestFunctionNameNotProvided => Some("GuestFunctionNameNotProvided"), - Self::GuestFunctionNotFound => Some("GuestFunctionNotFound"), - Self::GuestFunctionIncorrecNoOfParameters => { - Some("GuestFunctionIncorrecNoOfParameters") - } - Self::GispatchFunctionPointerNotSet => Some("GispatchFunctionPointerNotSet"), - Self::OutbError => Some("OutbError"), - Self::UnknownError => Some("UnknownError"), - Self::StackOverflow => Some("StackOverflow"), - Self::GsCheckFailed => Some("GsCheckFailed"), - Self::TooManyGuestFunctions => Some("TooManyGuestFunctions"), - Self::FailureInDlmalloc => Some("FailureInDlmalloc"), - Self::MallocFailed => Some("MallocFailed"), - Self::GuestFunctionParameterTypeMismatch => Some("GuestFunctionParameterTypeMismatch"), - Self::GuestError => Some("GuestError"), - Self::ArrayLengthParamIsMissing => Some("ArrayLengthParamIsMissing"), - Self::HostError => Some("HostError"), - _ => None, - } - } -} -impl core::fmt::Debug for ErrorCode { - 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 ErrorCode { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl flatbuffers::Push for ErrorCode { - type Output = ErrorCode; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { - flatbuffers::emplace_scalar::(dst, self.0); - } - } -} - -impl flatbuffers::EndianScalar for ErrorCode { - type Scalar = u64; - #[inline] - fn to_little_endian(self) -> u64 { - self.0.to_le() - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(v: u64) -> Self { - let b = u64::from_le(v); - Self(b) - } -} - -impl<'a> flatbuffers::Verifiable for ErrorCode { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - u64::run_verifier(v, pos) - } -} - -impl flatbuffers::SimpleToVerifyInSlice for ErrorCode {} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_generated.rs deleted file mode 100644 index 7ea5b4d63..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_generated.rs +++ /dev/null @@ -1,239 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum FunctionCallOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct FunctionCall<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for FunctionCall<'a> { - type Inner = FunctionCall<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> FunctionCall<'a> { - pub const VT_FUNCTION_NAME: flatbuffers::VOffsetT = 4; - pub const VT_PARAMETERS: flatbuffers::VOffsetT = 6; - pub const VT_FUNCTION_CALL_TYPE: flatbuffers::VOffsetT = 8; - pub const VT_EXPECTED_RETURN_TYPE: flatbuffers::VOffsetT = 10; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - FunctionCall { _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 FunctionCallArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = FunctionCallBuilder::new(_fbb); - if let Some(x) = args.parameters { - builder.add_parameters(x); - } - if let Some(x) = args.function_name { - builder.add_function_name(x); - } - builder.add_expected_return_type(args.expected_return_type); - builder.add_function_call_type(args.function_call_type); - builder.finish() - } - - #[inline] - pub fn function_name(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(FunctionCall::VT_FUNCTION_NAME, None) - .unwrap() - } - } - #[inline] - pub fn key_compare_less_than(&self, o: &FunctionCall) -> bool { - self.function_name() < o.function_name() - } - - #[inline] - pub fn key_compare_with_value(&self, val: &str) -> ::core::cmp::Ordering { - let key = self.function_name(); - key.cmp(val) - } - #[inline] - pub fn parameters( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(FunctionCall::VT_PARAMETERS, None) - } - } - #[inline] - pub fn function_call_type(&self) -> FunctionCallType { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::( - FunctionCall::VT_FUNCTION_CALL_TYPE, - Some(FunctionCallType::none), - ) - .unwrap() - } - } - #[inline] - pub fn expected_return_type(&self) -> ReturnType { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::( - FunctionCall::VT_EXPECTED_RETURN_TYPE, - Some(ReturnType::hlint), - ) - .unwrap() - } - } -} - -impl flatbuffers::Verifiable for FunctionCall<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>( - "function_name", - Self::VT_FUNCTION_NAME, - true, - )? - .visit_field::>, - >>("parameters", Self::VT_PARAMETERS, false)? - .visit_field::( - "function_call_type", - Self::VT_FUNCTION_CALL_TYPE, - false, - )? - .visit_field::( - "expected_return_type", - Self::VT_EXPECTED_RETURN_TYPE, - false, - )? - .finish(); - Ok(()) - } -} -pub struct FunctionCallArgs<'a> { - pub function_name: Option>, - pub parameters: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, - pub function_call_type: FunctionCallType, - pub expected_return_type: ReturnType, -} -impl<'a> Default for FunctionCallArgs<'a> { - #[inline] - fn default() -> Self { - FunctionCallArgs { - function_name: None, // required field - parameters: None, - function_call_type: FunctionCallType::none, - expected_return_type: ReturnType::hlint, - } - } -} - -pub struct FunctionCallBuilder<'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> FunctionCallBuilder<'a, 'b, A> { - #[inline] - pub fn add_function_name(&mut self, function_name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>( - FunctionCall::VT_FUNCTION_NAME, - function_name, - ); - } - #[inline] - pub fn add_parameters( - &mut self, - parameters: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(FunctionCall::VT_PARAMETERS, parameters); - } - #[inline] - pub fn add_function_call_type(&mut self, function_call_type: FunctionCallType) { - self.fbb_.push_slot::( - FunctionCall::VT_FUNCTION_CALL_TYPE, - function_call_type, - FunctionCallType::none, - ); - } - #[inline] - pub fn add_expected_return_type(&mut self, expected_return_type: ReturnType) { - self.fbb_.push_slot::( - FunctionCall::VT_EXPECTED_RETURN_TYPE, - expected_return_type, - ReturnType::hlint, - ); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> FunctionCallBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - FunctionCallBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_ - .required(o, FunctionCall::VT_FUNCTION_NAME, "function_name"); - flatbuffers::WIPOffset::new(o.value()) - } -} - -impl core::fmt::Debug for FunctionCall<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("FunctionCall"); - ds.field("function_name", &self.function_name()); - ds.field("parameters", &self.parameters()); - ds.field("function_call_type", &self.function_call_type()); - ds.field("expected_return_type", &self.expected_return_type()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_result_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_result_generated.rs deleted file mode 100644 index 7f26e9c00..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_result_generated.rs +++ /dev/null @@ -1,223 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum FunctionCallResultOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct FunctionCallResult<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for FunctionCallResult<'a> { - type Inner = FunctionCallResult<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> FunctionCallResult<'a> { - pub const VT_RESULT_TYPE: flatbuffers::VOffsetT = 4; - pub const VT_RESULT: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - FunctionCallResult { _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 FunctionCallResultArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = FunctionCallResultBuilder::new(_fbb); - if let Some(x) = args.result { - builder.add_result(x); - } - builder.add_result_type(args.result_type); - builder.finish() - } - - #[inline] - pub fn result_type(&self) -> FunctionCallResultType { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::( - FunctionCallResult::VT_RESULT_TYPE, - Some(FunctionCallResultType::NONE), - ) - .unwrap() - } - } - #[inline] - pub fn result(&self) -> flatbuffers::Table<'a> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - FunctionCallResult::VT_RESULT, - None, - ) - .unwrap() - } - } - #[inline] - #[allow(non_snake_case)] - pub fn result_as_return_value_box(&self) -> Option> { - if self.result_type() == FunctionCallResultType::ReturnValueBox { - let u = self.result(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { ReturnValueBox::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn result_as_guest_error(&self) -> Option> { - if self.result_type() == FunctionCallResultType::GuestError { - let u = self.result(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { GuestError::init_from_table(u) }) - } else { - None - } - } -} - -impl flatbuffers::Verifiable for FunctionCallResult<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_union::( - "result_type", - Self::VT_RESULT_TYPE, - "result", - Self::VT_RESULT, - true, - |key, v, pos| match key { - FunctionCallResultType::ReturnValueBox => v - .verify_union_variant::>( - "FunctionCallResultType::ReturnValueBox", - pos, - ), - FunctionCallResultType::GuestError => v - .verify_union_variant::>( - "FunctionCallResultType::GuestError", - pos, - ), - _ => Ok(()), - }, - )? - .finish(); - Ok(()) - } -} -pub struct FunctionCallResultArgs { - pub result_type: FunctionCallResultType, - pub result: Option>, -} -impl<'a> Default for FunctionCallResultArgs { - #[inline] - fn default() -> Self { - FunctionCallResultArgs { - result_type: FunctionCallResultType::NONE, - result: None, // required field - } - } -} - -pub struct FunctionCallResultBuilder<'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> FunctionCallResultBuilder<'a, 'b, A> { - #[inline] - pub fn add_result_type(&mut self, result_type: FunctionCallResultType) { - self.fbb_.push_slot::( - FunctionCallResult::VT_RESULT_TYPE, - result_type, - FunctionCallResultType::NONE, - ); - } - #[inline] - pub fn add_result(&mut self, result: flatbuffers::WIPOffset) { - self.fbb_ - .push_slot_always::>(FunctionCallResult::VT_RESULT, result); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> FunctionCallResultBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - FunctionCallResultBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_ - .required(o, FunctionCallResult::VT_RESULT, "result"); - flatbuffers::WIPOffset::new(o.value()) - } -} - -impl core::fmt::Debug for FunctionCallResult<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("FunctionCallResult"); - ds.field("result_type", &self.result_type()); - match self.result_type() { - FunctionCallResultType::ReturnValueBox => { - if let Some(x) = self.result_as_return_value_box() { - ds.field("result", &x) - } else { - ds.field( - "result", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - FunctionCallResultType::GuestError => { - if let Some(x) = self.result_as_guest_error() { - ds.field("result", &x) - } else { - ds.field( - "result", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - _ => { - let x: Option<()> = None; - ds.field("result", &x) - } - }; - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_result_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_result_type_generated.rs deleted file mode 100644 index 0c54dfed4..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_result_type_generated.rs +++ /dev/null @@ -1,110 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MIN_FUNCTION_CALL_RESULT_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_FUNCTION_CALL_RESULT_TYPE: u8 = 2; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -#[allow(non_camel_case_types)] -pub const ENUM_VALUES_FUNCTION_CALL_RESULT_TYPE: [FunctionCallResultType; 3] = [ - FunctionCallResultType::NONE, - FunctionCallResultType::ReturnValueBox, - FunctionCallResultType::GuestError, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct FunctionCallResultType(pub u8); -#[allow(non_upper_case_globals)] -impl FunctionCallResultType { - pub const NONE: Self = Self(0); - pub const ReturnValueBox: Self = Self(1); - pub const GuestError: Self = Self(2); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 2; - pub const ENUM_VALUES: &'static [Self] = &[Self::NONE, Self::ReturnValueBox, Self::GuestError]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::NONE => Some("NONE"), - Self::ReturnValueBox => Some("ReturnValueBox"), - Self::GuestError => Some("GuestError"), - _ => None, - } - } -} -impl core::fmt::Debug for FunctionCallResultType { - 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 FunctionCallResultType { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl flatbuffers::Push for FunctionCallResultType { - type Output = FunctionCallResultType; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { - flatbuffers::emplace_scalar::(dst, self.0); - } - } -} - -impl flatbuffers::EndianScalar for FunctionCallResultType { - 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 FunctionCallResultType { - #[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 FunctionCallResultType {} -pub struct FunctionCallResultTypeUnionTableOffset {} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_type_generated.rs deleted file mode 100644 index 84356d89a..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_type_generated.rs +++ /dev/null @@ -1,109 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MIN_FUNCTION_CALL_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_FUNCTION_CALL_TYPE: u8 = 2; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -#[allow(non_camel_case_types)] -pub const ENUM_VALUES_FUNCTION_CALL_TYPE: [FunctionCallType; 3] = [ - FunctionCallType::none, - FunctionCallType::guest, - FunctionCallType::host, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct FunctionCallType(pub u8); -#[allow(non_upper_case_globals)] -impl FunctionCallType { - pub const none: Self = Self(0); - pub const guest: Self = Self(1); - pub const host: Self = Self(2); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 2; - pub const ENUM_VALUES: &'static [Self] = &[Self::none, Self::guest, Self::host]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::none => Some("none"), - Self::guest => Some("guest"), - Self::host => Some("host"), - _ => None, - } - } -} -impl core::fmt::Debug for FunctionCallType { - 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 FunctionCallType { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl flatbuffers::Push for FunctionCallType { - type Output = FunctionCallType; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { - flatbuffers::emplace_scalar::(dst, self.0); - } - } -} - -impl flatbuffers::EndianScalar for FunctionCallType { - 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 FunctionCallType { - #[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 FunctionCallType {} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_error_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_error_generated.rs deleted file mode 100644 index 21ef559b6..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_error_generated.rs +++ /dev/null @@ -1,141 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum GuestErrorOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct GuestError<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for GuestError<'a> { - type Inner = GuestError<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> GuestError<'a> { - pub const VT_CODE: flatbuffers::VOffsetT = 4; - pub const VT_MESSAGE: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - GuestError { _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 GuestErrorArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = GuestErrorBuilder::new(_fbb); - builder.add_code(args.code); - if let Some(x) = args.message { - builder.add_message(x); - } - builder.finish() - } - - #[inline] - pub fn code(&self) -> ErrorCode { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(GuestError::VT_CODE, Some(ErrorCode::NoError)) - .unwrap() - } - } - #[inline] - pub fn message(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(GuestError::VT_MESSAGE, None) - } - } -} - -impl flatbuffers::Verifiable for GuestError<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("code", Self::VT_CODE, false)? - .visit_field::>("message", Self::VT_MESSAGE, false)? - .finish(); - Ok(()) - } -} -pub struct GuestErrorArgs<'a> { - pub code: ErrorCode, - pub message: Option>, -} -impl<'a> Default for GuestErrorArgs<'a> { - #[inline] - fn default() -> Self { - GuestErrorArgs { - code: ErrorCode::NoError, - message: None, - } - } -} - -pub struct GuestErrorBuilder<'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> GuestErrorBuilder<'a, 'b, A> { - #[inline] - pub fn add_code(&mut self, code: ErrorCode) { - self.fbb_ - .push_slot::(GuestError::VT_CODE, code, ErrorCode::NoError); - } - #[inline] - pub fn add_message(&mut self, message: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(GuestError::VT_MESSAGE, message); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> GuestErrorBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - GuestErrorBuilder { - 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 GuestError<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("GuestError"); - ds.field("code", &self.code()); - ds.field("message", &self.message()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_envelope_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_envelope_type_generated.rs deleted file mode 100644 index 80e24505a..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_envelope_type_generated.rs +++ /dev/null @@ -1,312 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum GuestEventEnvelopeTypeOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct GuestEventEnvelopeType<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for GuestEventEnvelopeType<'a> { - type Inner = GuestEventEnvelopeType<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> GuestEventEnvelopeType<'a> { - pub const VT_EVENT_TYPE: flatbuffers::VOffsetT = 4; - pub const VT_EVENT: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - GuestEventEnvelopeType { _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 GuestEventEnvelopeTypeArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = GuestEventEnvelopeTypeBuilder::new(_fbb); - if let Some(x) = args.event { - builder.add_event(x); - } - builder.add_event_type(args.event_type); - builder.finish() - } - - #[inline] - pub fn event_type(&self) -> GuestEventType { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::( - GuestEventEnvelopeType::VT_EVENT_TYPE, - Some(GuestEventType::NONE), - ) - .unwrap() - } - } - #[inline] - pub fn event(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - GuestEventEnvelopeType::VT_EVENT, - None, - ) - } - } - #[inline] - #[allow(non_snake_case)] - pub fn event_as_open_span(&self) -> Option> { - if self.event_type() == GuestEventType::OpenSpan { - self.event().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { OpenSpanType::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn event_as_close_span(&self) -> Option> { - if self.event_type() == GuestEventType::CloseSpan { - self.event().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { CloseSpanType::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn event_as_log_event(&self) -> Option> { - if self.event_type() == GuestEventType::LogEvent { - self.event().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { LogEventType::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn event_as_edit_span(&self) -> Option> { - if self.event_type() == GuestEventType::EditSpan { - self.event().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { EditSpanType::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn event_as_guest_start(&self) -> Option> { - if self.event_type() == GuestEventType::GuestStart { - self.event().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { GuestStartType::init_from_table(t) } - }) - } else { - None - } - } -} - -impl flatbuffers::Verifiable for GuestEventEnvelopeType<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_union::( - "event_type", - Self::VT_EVENT_TYPE, - "event", - Self::VT_EVENT, - false, - |key, v, pos| match key { - GuestEventType::OpenSpan => v - .verify_union_variant::>( - "GuestEventType::OpenSpan", - pos, - ), - GuestEventType::CloseSpan => v - .verify_union_variant::>( - "GuestEventType::CloseSpan", - pos, - ), - GuestEventType::LogEvent => v - .verify_union_variant::>( - "GuestEventType::LogEvent", - pos, - ), - GuestEventType::EditSpan => v - .verify_union_variant::>( - "GuestEventType::EditSpan", - pos, - ), - GuestEventType::GuestStart => v - .verify_union_variant::>( - "GuestEventType::GuestStart", - pos, - ), - _ => Ok(()), - }, - )? - .finish(); - Ok(()) - } -} -pub struct GuestEventEnvelopeTypeArgs { - pub event_type: GuestEventType, - pub event: Option>, -} -impl<'a> Default for GuestEventEnvelopeTypeArgs { - #[inline] - fn default() -> Self { - GuestEventEnvelopeTypeArgs { - event_type: GuestEventType::NONE, - event: None, - } - } -} - -pub struct GuestEventEnvelopeTypeBuilder<'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> GuestEventEnvelopeTypeBuilder<'a, 'b, A> { - #[inline] - pub fn add_event_type(&mut self, event_type: GuestEventType) { - self.fbb_.push_slot::( - GuestEventEnvelopeType::VT_EVENT_TYPE, - event_type, - GuestEventType::NONE, - ); - } - #[inline] - pub fn add_event(&mut self, event: flatbuffers::WIPOffset) { - self.fbb_ - .push_slot_always::>(GuestEventEnvelopeType::VT_EVENT, event); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> GuestEventEnvelopeTypeBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - GuestEventEnvelopeTypeBuilder { - 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 GuestEventEnvelopeType<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("GuestEventEnvelopeType"); - ds.field("event_type", &self.event_type()); - match self.event_type() { - GuestEventType::OpenSpan => { - if let Some(x) = self.event_as_open_span() { - ds.field("event", &x) - } else { - ds.field( - "event", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - GuestEventType::CloseSpan => { - if let Some(x) = self.event_as_close_span() { - ds.field("event", &x) - } else { - ds.field( - "event", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - GuestEventType::LogEvent => { - if let Some(x) = self.event_as_log_event() { - ds.field("event", &x) - } else { - ds.field( - "event", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - GuestEventType::EditSpan => { - if let Some(x) = self.event_as_edit_span() { - ds.field("event", &x) - } else { - ds.field( - "event", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - GuestEventType::GuestStart => { - if let Some(x) = self.event_as_guest_start() { - ds.field("event", &x) - } else { - ds.field( - "event", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - _ => { - let x: Option<()> = None; - ds.field("event", &x) - } - }; - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_generated.rs deleted file mode 100644 index 1d89bd9c7..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_generated.rs +++ /dev/null @@ -1,249 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum GuestEventOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct GuestEvent<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for GuestEvent<'a> { - type Inner = GuestEvent<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> GuestEvent<'a> { - pub const VT_EVENT_TYPE: flatbuffers::VOffsetT = 4; - pub const VT_EVENT: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - GuestEvent { _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 GuestEventArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = GuestEventBuilder::new(_fbb); - if let Some(x) = args.event { - builder.add_event(x); - } - builder.add_event_type(args.event_type); - builder.finish() - } - - #[inline] - pub fn event_type(&self) -> GuestEventType { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(GuestEvent::VT_EVENT_TYPE, Some(GuestEventType::NONE)) - .unwrap() - } - } - #[inline] - pub fn event(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - GuestEvent::VT_EVENT, - None, - ) - } - } - #[inline] - #[allow(non_snake_case)] - pub fn event_as_open_span_type(&self) -> Option> { - if self.event_type() == GuestEventType::OpenSpanType { - self.event().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { OpenSpanType::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn event_as_close_span_type(&self) -> Option> { - if self.event_type() == GuestEventType::CloseSpanType { - self.event().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { CloseSpanType::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn event_as_log_event_type(&self) -> Option> { - if self.event_type() == GuestEventType::LogEventType { - self.event().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { LogEventType::init_from_table(t) } - }) - } else { - None - } - } -} - -impl flatbuffers::Verifiable for GuestEvent<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_union::( - "event_type", - Self::VT_EVENT_TYPE, - "event", - Self::VT_EVENT, - false, - |key, v, pos| match key { - GuestEventType::OpenSpanType => v - .verify_union_variant::>( - "GuestEventType::OpenSpanType", - pos, - ), - GuestEventType::CloseSpanType => v - .verify_union_variant::>( - "GuestEventType::CloseSpanType", - pos, - ), - GuestEventType::LogEventType => v - .verify_union_variant::>( - "GuestEventType::LogEventType", - pos, - ), - _ => Ok(()), - }, - )? - .finish(); - Ok(()) - } -} -pub struct GuestEventArgs { - pub event_type: GuestEventType, - pub event: Option>, -} -impl<'a> Default for GuestEventArgs { - #[inline] - fn default() -> Self { - GuestEventArgs { - event_type: GuestEventType::NONE, - event: None, - } - } -} - -pub struct GuestEventBuilder<'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> GuestEventBuilder<'a, 'b, A> { - #[inline] - pub fn add_event_type(&mut self, event_type: GuestEventType) { - self.fbb_.push_slot::( - GuestEvent::VT_EVENT_TYPE, - event_type, - GuestEventType::NONE, - ); - } - #[inline] - pub fn add_event(&mut self, event: flatbuffers::WIPOffset) { - self.fbb_ - .push_slot_always::>(GuestEvent::VT_EVENT, event); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> GuestEventBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - GuestEventBuilder { - 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 GuestEvent<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("GuestEvent"); - ds.field("event_type", &self.event_type()); - match self.event_type() { - GuestEventType::OpenSpanType => { - if let Some(x) = self.event_as_open_span_type() { - ds.field("event", &x) - } else { - ds.field( - "event", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - GuestEventType::CloseSpanType => { - if let Some(x) = self.event_as_close_span_type() { - ds.field("event", &x) - } else { - ds.field( - "event", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - GuestEventType::LogEventType => { - if let Some(x) = self.event_as_log_event_type() { - ds.field("event", &x) - } else { - ds.field( - "event", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - _ => { - let x: Option<()> = None; - ds.field("event", &x) - } - }; - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_type_generated.rs deleted file mode 100644 index 07a343a30..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_type_generated.rs +++ /dev/null @@ -1,126 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MIN_GUEST_EVENT_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_GUEST_EVENT_TYPE: u8 = 5; -#[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_GUEST_EVENT_TYPE: [GuestEventType; 6] = [ - GuestEventType::NONE, - GuestEventType::OpenSpan, - GuestEventType::CloseSpan, - GuestEventType::LogEvent, - GuestEventType::EditSpan, - GuestEventType::GuestStart, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct GuestEventType(pub u8); -#[allow(non_upper_case_globals)] -impl GuestEventType { - pub const NONE: Self = Self(0); - pub const OpenSpan: Self = Self(1); - pub const CloseSpan: Self = Self(2); - pub const LogEvent: Self = Self(3); - pub const EditSpan: Self = Self(4); - pub const GuestStart: Self = Self(5); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 5; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::NONE, - Self::OpenSpan, - Self::CloseSpan, - Self::LogEvent, - Self::EditSpan, - Self::GuestStart, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::NONE => Some("NONE"), - Self::OpenSpan => Some("OpenSpan"), - Self::CloseSpan => Some("CloseSpan"), - Self::LogEvent => Some("LogEvent"), - Self::EditSpan => Some("EditSpan"), - Self::GuestStart => Some("GuestStart"), - _ => None, - } - } -} -impl core::fmt::Debug for GuestEventType { - 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 GuestEventType { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl flatbuffers::Push for GuestEventType { - type Output = GuestEventType; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { - flatbuffers::emplace_scalar::(dst, self.0); - } - } -} - -impl flatbuffers::EndianScalar for GuestEventType { - 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 GuestEventType { - #[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 GuestEventType {} -pub struct GuestEventTypeUnionTableOffset {} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_union_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_union_type_generated.rs deleted file mode 100644 index 211b0ba12..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_event_union_type_generated.rs +++ /dev/null @@ -1,126 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MIN_GUEST_EVENT_UNION_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_GUEST_EVENT_UNION_TYPE: u8 = 5; -#[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_GUEST_EVENT_UNION_TYPE: [GuestEventUnionType; 6] = [ - GuestEventUnionType::NONE, - GuestEventUnionType::OpenSpan, - GuestEventUnionType::CloseSpan, - GuestEventUnionType::LogEvent, - GuestEventUnionType::EditSpan, - GuestEventUnionType::GuestStart, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct GuestEventUnionType(pub u8); -#[allow(non_upper_case_globals)] -impl GuestEventUnionType { - pub const NONE: Self = Self(0); - pub const OpenSpan: Self = Self(1); - pub const CloseSpan: Self = Self(2); - pub const LogEvent: Self = Self(3); - pub const EditSpan: Self = Self(4); - pub const GuestStart: Self = Self(5); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 5; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::NONE, - Self::OpenSpan, - Self::CloseSpan, - Self::LogEvent, - Self::EditSpan, - Self::GuestStart, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::NONE => Some("NONE"), - Self::OpenSpan => Some("OpenSpan"), - Self::CloseSpan => Some("CloseSpan"), - Self::LogEvent => Some("LogEvent"), - Self::EditSpan => Some("EditSpan"), - Self::GuestStart => Some("GuestStart"), - _ => None, - } - } -} -impl core::fmt::Debug for GuestEventUnionType { - 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 GuestEventUnionType { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl flatbuffers::Push for GuestEventUnionType { - type Output = GuestEventUnionType; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { - flatbuffers::emplace_scalar::(dst, self.0); - } - } -} - -impl flatbuffers::EndianScalar for GuestEventUnionType { - 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 GuestEventUnionType { - #[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 GuestEventUnionType {} -pub struct GuestEventUnionTypeUnionTableOffset {} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_log_data_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_log_data_generated.rs deleted file mode 100644 index d3de70427..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_log_data_generated.rs +++ /dev/null @@ -1,237 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum GuestLogDataOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct GuestLogData<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for GuestLogData<'a> { - type Inner = GuestLogData<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> GuestLogData<'a> { - pub const VT_MESSAGE: flatbuffers::VOffsetT = 4; - pub const VT_SOURCE: flatbuffers::VOffsetT = 6; - pub const VT_LEVEL: flatbuffers::VOffsetT = 8; - pub const VT_CALLER: flatbuffers::VOffsetT = 10; - pub const VT_SOURCE_FILE: flatbuffers::VOffsetT = 12; - pub const VT_LINE: flatbuffers::VOffsetT = 14; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - GuestLogData { _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 GuestLogDataArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = GuestLogDataBuilder::new(_fbb); - builder.add_line(args.line); - if let Some(x) = args.source_file { - builder.add_source_file(x); - } - if let Some(x) = args.caller { - builder.add_caller(x); - } - if let Some(x) = args.source { - builder.add_source(x); - } - if let Some(x) = args.message { - builder.add_message(x); - } - builder.add_level(args.level); - builder.finish() - } - - #[inline] - pub fn message(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(GuestLogData::VT_MESSAGE, None) - } - } - #[inline] - pub fn source(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(GuestLogData::VT_SOURCE, None) - } - } - #[inline] - pub fn level(&self) -> LogLevel { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(GuestLogData::VT_LEVEL, Some(LogLevel::Trace)) - .unwrap() - } - } - #[inline] - pub fn caller(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(GuestLogData::VT_CALLER, None) - } - } - #[inline] - pub fn source_file(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(GuestLogData::VT_SOURCE_FILE, None) - } - } - #[inline] - pub fn line(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(GuestLogData::VT_LINE, Some(0)) - .unwrap() - } - } -} - -impl flatbuffers::Verifiable for GuestLogData<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>("message", Self::VT_MESSAGE, false)? - .visit_field::>("source", Self::VT_SOURCE, false)? - .visit_field::("level", Self::VT_LEVEL, false)? - .visit_field::>("caller", Self::VT_CALLER, false)? - .visit_field::>( - "source_file", - Self::VT_SOURCE_FILE, - false, - )? - .visit_field::("line", Self::VT_LINE, false)? - .finish(); - Ok(()) - } -} -pub struct GuestLogDataArgs<'a> { - pub message: Option>, - pub source: Option>, - pub level: LogLevel, - pub caller: Option>, - pub source_file: Option>, - pub line: u32, -} -impl<'a> Default for GuestLogDataArgs<'a> { - #[inline] - fn default() -> Self { - GuestLogDataArgs { - message: None, - source: None, - level: LogLevel::Trace, - caller: None, - source_file: None, - line: 0, - } - } -} - -pub struct GuestLogDataBuilder<'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> GuestLogDataBuilder<'a, 'b, A> { - #[inline] - pub fn add_message(&mut self, message: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(GuestLogData::VT_MESSAGE, message); - } - #[inline] - pub fn add_source(&mut self, source: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(GuestLogData::VT_SOURCE, source); - } - #[inline] - pub fn add_level(&mut self, level: LogLevel) { - self.fbb_ - .push_slot::(GuestLogData::VT_LEVEL, level, LogLevel::Trace); - } - #[inline] - pub fn add_caller(&mut self, caller: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(GuestLogData::VT_CALLER, caller); - } - #[inline] - pub fn add_source_file(&mut self, source_file: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>( - GuestLogData::VT_SOURCE_FILE, - source_file, - ); - } - #[inline] - pub fn add_line(&mut self, line: u32) { - self.fbb_.push_slot::(GuestLogData::VT_LINE, line, 0); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> GuestLogDataBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - GuestLogDataBuilder { - 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 GuestLogData<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("GuestLogData"); - ds.field("message", &self.message()); - ds.field("source", &self.source()); - ds.field("level", &self.level()); - ds.field("caller", &self.caller()); - ds.field("source_file", &self.source_file()); - ds.field("line", &self.line()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_start_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_start_type_generated.rs deleted file mode 100644 index f47a43f1b..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_start_type_generated.rs +++ /dev/null @@ -1,115 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum GuestStartTypeOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct GuestStartType<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for GuestStartType<'a> { - type Inner = GuestStartType<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> GuestStartType<'a> { - pub const VT_TSC: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - GuestStartType { _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 GuestStartTypeArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = GuestStartTypeBuilder::new(_fbb); - builder.add_tsc(args.tsc); - builder.finish() - } - - #[inline] - pub fn tsc(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(GuestStartType::VT_TSC, Some(0)) - .unwrap() - } - } -} - -impl flatbuffers::Verifiable for GuestStartType<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("tsc", Self::VT_TSC, false)? - .finish(); - Ok(()) - } -} -pub struct GuestStartTypeArgs { - pub tsc: u64, -} -impl<'a> Default for GuestStartTypeArgs { - #[inline] - fn default() -> Self { - GuestStartTypeArgs { tsc: 0 } - } -} - -pub struct GuestStartTypeBuilder<'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> GuestStartTypeBuilder<'a, 'b, A> { - #[inline] - pub fn add_tsc(&mut self, tsc: u64) { - self.fbb_.push_slot::(GuestStartType::VT_TSC, tsc, 0); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> GuestStartTypeBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - GuestStartTypeBuilder { - 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 GuestStartType<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("GuestStartType"); - ds.field("tsc", &self.tsc()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlbool_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlbool_generated.rs deleted file mode 100644 index c4a2b6673..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlbool_generated.rs +++ /dev/null @@ -1,113 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum hlboolOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct hlbool<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for hlbool<'a> { - type Inner = hlbool<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> hlbool<'a> { - pub const VT_VALUE: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - hlbool { _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 hlboolArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = hlboolBuilder::new(_fbb); - builder.add_value(args.value); - builder.finish() - } - - #[inline] - pub fn value(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(hlbool::VT_VALUE, Some(false)) - .unwrap() - } - } -} - -impl flatbuffers::Verifiable for hlbool<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("value", Self::VT_VALUE, false)? - .finish(); - Ok(()) - } -} -pub struct hlboolArgs { - pub value: bool, -} -impl<'a> Default for hlboolArgs { - #[inline] - fn default() -> Self { - hlboolArgs { value: false } - } -} - -pub struct hlboolBuilder<'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> hlboolBuilder<'a, 'b, A> { - #[inline] - pub fn add_value(&mut self, value: bool) { - self.fbb_.push_slot::(hlbool::VT_VALUE, value, false); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> hlboolBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - hlboolBuilder { - 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 hlbool<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("hlbool"); - ds.field("value", &self.value()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hldouble_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hldouble_generated.rs deleted file mode 100644 index 0cbabb8b1..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hldouble_generated.rs +++ /dev/null @@ -1,109 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum hldoubleOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct hldouble<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for hldouble<'a> { - type Inner = hldouble<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> hldouble<'a> { - pub const VT_VALUE: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - hldouble { _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 hldoubleArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = hldoubleBuilder::new(_fbb); - builder.add_value(args.value); - builder.finish() - } - - #[inline] - pub fn value(&self) -> f64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(hldouble::VT_VALUE, Some(0.0)).unwrap() } - } -} - -impl flatbuffers::Verifiable for hldouble<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("value", Self::VT_VALUE, false)? - .finish(); - Ok(()) - } -} -pub struct hldoubleArgs { - pub value: f64, -} -impl<'a> Default for hldoubleArgs { - #[inline] - fn default() -> Self { - hldoubleArgs { value: 0.0 } - } -} - -pub struct hldoubleBuilder<'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> hldoubleBuilder<'a, 'b, A> { - #[inline] - pub fn add_value(&mut self, value: f64) { - self.fbb_.push_slot::(hldouble::VT_VALUE, value, 0.0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> hldoubleBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - hldoubleBuilder { - 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 hldouble<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("hldouble"); - ds.field("value", &self.value()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlfloat_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlfloat_generated.rs deleted file mode 100644 index ca59467d4..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlfloat_generated.rs +++ /dev/null @@ -1,109 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum hlfloatOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct hlfloat<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for hlfloat<'a> { - type Inner = hlfloat<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> hlfloat<'a> { - pub const VT_VALUE: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - hlfloat { _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 hlfloatArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = hlfloatBuilder::new(_fbb); - builder.add_value(args.value); - builder.finish() - } - - #[inline] - pub fn value(&self) -> f32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(hlfloat::VT_VALUE, Some(0.0)).unwrap() } - } -} - -impl flatbuffers::Verifiable for hlfloat<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("value", Self::VT_VALUE, false)? - .finish(); - Ok(()) - } -} -pub struct hlfloatArgs { - pub value: f32, -} -impl<'a> Default for hlfloatArgs { - #[inline] - fn default() -> Self { - hlfloatArgs { value: 0.0 } - } -} - -pub struct hlfloatBuilder<'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> hlfloatBuilder<'a, 'b, A> { - #[inline] - pub fn add_value(&mut self, value: f32) { - self.fbb_.push_slot::(hlfloat::VT_VALUE, value, 0.0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> hlfloatBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - hlfloatBuilder { - 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 hlfloat<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("hlfloat"); - ds.field("value", &self.value()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlint_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlint_generated.rs deleted file mode 100644 index 726f3ba29..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlint_generated.rs +++ /dev/null @@ -1,109 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum hlintOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct hlint<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for hlint<'a> { - type Inner = hlint<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> hlint<'a> { - pub const VT_VALUE: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - hlint { _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 hlintArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = hlintBuilder::new(_fbb); - builder.add_value(args.value); - builder.finish() - } - - #[inline] - pub fn value(&self) -> i32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(hlint::VT_VALUE, Some(0)).unwrap() } - } -} - -impl flatbuffers::Verifiable for hlint<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("value", Self::VT_VALUE, false)? - .finish(); - Ok(()) - } -} -pub struct hlintArgs { - pub value: i32, -} -impl<'a> Default for hlintArgs { - #[inline] - fn default() -> Self { - hlintArgs { value: 0 } - } -} - -pub struct hlintBuilder<'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> hlintBuilder<'a, 'b, A> { - #[inline] - pub fn add_value(&mut self, value: i32) { - self.fbb_.push_slot::(hlint::VT_VALUE, value, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> hlintBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - hlintBuilder { - 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 hlint<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("hlint"); - ds.field("value", &self.value()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hllong_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hllong_generated.rs deleted file mode 100644 index 7c088ff8c..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hllong_generated.rs +++ /dev/null @@ -1,109 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum hllongOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct hllong<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for hllong<'a> { - type Inner = hllong<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> hllong<'a> { - pub const VT_VALUE: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - hllong { _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 hllongArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = hllongBuilder::new(_fbb); - builder.add_value(args.value); - builder.finish() - } - - #[inline] - pub fn value(&self) -> i64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(hllong::VT_VALUE, Some(0)).unwrap() } - } -} - -impl flatbuffers::Verifiable for hllong<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("value", Self::VT_VALUE, false)? - .finish(); - Ok(()) - } -} -pub struct hllongArgs { - pub value: i64, -} -impl<'a> Default for hllongArgs { - #[inline] - fn default() -> Self { - hllongArgs { value: 0 } - } -} - -pub struct hllongBuilder<'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> hllongBuilder<'a, 'b, A> { - #[inline] - pub fn add_value(&mut self, value: i64) { - self.fbb_.push_slot::(hllong::VT_VALUE, value, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> hllongBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - hllongBuilder { - 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 hllong<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("hllong"); - ds.field("value", &self.value()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlsizeprefixedbuffer_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlsizeprefixedbuffer_generated.rs deleted file mode 100644 index cbbb2729c..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlsizeprefixedbuffer_generated.rs +++ /dev/null @@ -1,148 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum hlsizeprefixedbufferOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct hlsizeprefixedbuffer<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for hlsizeprefixedbuffer<'a> { - type Inner = hlsizeprefixedbuffer<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> hlsizeprefixedbuffer<'a> { - pub const VT_SIZE: flatbuffers::VOffsetT = 4; - pub const VT_VALUE: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - hlsizeprefixedbuffer { _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 hlsizeprefixedbufferArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = hlsizeprefixedbufferBuilder::new(_fbb); - if let Some(x) = args.value { - builder.add_value(x); - } - builder.add_size(args.size); - builder.finish() - } - - #[inline] - pub fn size(&self) -> i32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(hlsizeprefixedbuffer::VT_SIZE, Some(0)) - .unwrap() - } - } - #[inline] - pub fn value(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - hlsizeprefixedbuffer::VT_VALUE, - None, - ) - } - } -} - -impl flatbuffers::Verifiable for hlsizeprefixedbuffer<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("size", Self::VT_SIZE, false)? - .visit_field::>>( - "value", - Self::VT_VALUE, - false, - )? - .finish(); - Ok(()) - } -} -pub struct hlsizeprefixedbufferArgs<'a> { - pub size: i32, - pub value: Option>>, -} -impl<'a> Default for hlsizeprefixedbufferArgs<'a> { - #[inline] - fn default() -> Self { - hlsizeprefixedbufferArgs { - size: 0, - value: None, - } - } -} - -pub struct hlsizeprefixedbufferBuilder<'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> hlsizeprefixedbufferBuilder<'a, 'b, A> { - #[inline] - pub fn add_size(&mut self, size: i32) { - self.fbb_ - .push_slot::(hlsizeprefixedbuffer::VT_SIZE, size, 0); - } - #[inline] - pub fn add_value(&mut self, value: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>(hlsizeprefixedbuffer::VT_VALUE, value); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> hlsizeprefixedbufferBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - hlsizeprefixedbufferBuilder { - 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 hlsizeprefixedbuffer<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("hlsizeprefixedbuffer"); - ds.field("size", &self.size()); - ds.field("value", &self.value()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlstring_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlstring_generated.rs deleted file mode 100644 index cb2d7db09..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlstring_generated.rs +++ /dev/null @@ -1,115 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum hlstringOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct hlstring<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for hlstring<'a> { - type Inner = hlstring<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> hlstring<'a> { - pub const VT_VALUE: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - hlstring { _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 hlstringArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = hlstringBuilder::new(_fbb); - if let Some(x) = args.value { - builder.add_value(x); - } - builder.finish() - } - - #[inline] - pub fn value(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(hlstring::VT_VALUE, None) - } - } -} - -impl flatbuffers::Verifiable for hlstring<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>("value", Self::VT_VALUE, false)? - .finish(); - Ok(()) - } -} -pub struct hlstringArgs<'a> { - pub value: Option>, -} -impl<'a> Default for hlstringArgs<'a> { - #[inline] - fn default() -> Self { - hlstringArgs { value: None } - } -} - -pub struct hlstringBuilder<'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> hlstringBuilder<'a, 'b, A> { - #[inline] - pub fn add_value(&mut self, value: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(hlstring::VT_VALUE, value); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> hlstringBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - hlstringBuilder { - 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 hlstring<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("hlstring"); - ds.field("value", &self.value()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hluint_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hluint_generated.rs deleted file mode 100644 index 67f8cbd6d..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hluint_generated.rs +++ /dev/null @@ -1,109 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum hluintOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct hluint<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for hluint<'a> { - type Inner = hluint<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> hluint<'a> { - pub const VT_VALUE: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - hluint { _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 hluintArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = hluintBuilder::new(_fbb); - builder.add_value(args.value); - builder.finish() - } - - #[inline] - pub fn value(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(hluint::VT_VALUE, Some(0)).unwrap() } - } -} - -impl flatbuffers::Verifiable for hluint<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("value", Self::VT_VALUE, false)? - .finish(); - Ok(()) - } -} -pub struct hluintArgs { - pub value: u32, -} -impl<'a> Default for hluintArgs { - #[inline] - fn default() -> Self { - hluintArgs { value: 0 } - } -} - -pub struct hluintBuilder<'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> hluintBuilder<'a, 'b, A> { - #[inline] - pub fn add_value(&mut self, value: u32) { - self.fbb_.push_slot::(hluint::VT_VALUE, value, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> hluintBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - hluintBuilder { - 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 hluint<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("hluint"); - ds.field("value", &self.value()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlulong_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlulong_generated.rs deleted file mode 100644 index f701f3d6c..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlulong_generated.rs +++ /dev/null @@ -1,109 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum hlulongOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct hlulong<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for hlulong<'a> { - type Inner = hlulong<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> hlulong<'a> { - pub const VT_VALUE: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - hlulong { _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 hlulongArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = hlulongBuilder::new(_fbb); - builder.add_value(args.value); - builder.finish() - } - - #[inline] - pub fn value(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(hlulong::VT_VALUE, Some(0)).unwrap() } - } -} - -impl flatbuffers::Verifiable for hlulong<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("value", Self::VT_VALUE, false)? - .finish(); - Ok(()) - } -} -pub struct hlulongArgs { - pub value: u64, -} -impl<'a> Default for hlulongArgs { - #[inline] - fn default() -> Self { - hlulongArgs { value: 0 } - } -} - -pub struct hlulongBuilder<'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> hlulongBuilder<'a, 'b, A> { - #[inline] - pub fn add_value(&mut self, value: u64) { - self.fbb_.push_slot::(hlulong::VT_VALUE, value, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> hlulongBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - hlulongBuilder { - 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 hlulong<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("hlulong"); - ds.field("value", &self.value()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvecbytes_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvecbytes_generated.rs deleted file mode 100644 index 8b1c4a109..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvecbytes_generated.rs +++ /dev/null @@ -1,124 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum hlvecbytesOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct hlvecbytes<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for hlvecbytes<'a> { - type Inner = hlvecbytes<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> hlvecbytes<'a> { - pub const VT_VALUE: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - hlvecbytes { _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 hlvecbytesArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = hlvecbytesBuilder::new(_fbb); - if let Some(x) = args.value { - builder.add_value(x); - } - builder.finish() - } - - #[inline] - pub fn value(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - hlvecbytes::VT_VALUE, - None, - ) - } - } -} - -impl flatbuffers::Verifiable for hlvecbytes<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>>( - "value", - Self::VT_VALUE, - false, - )? - .finish(); - Ok(()) - } -} -pub struct hlvecbytesArgs<'a> { - pub value: Option>>, -} -impl<'a> Default for hlvecbytesArgs<'a> { - #[inline] - fn default() -> Self { - hlvecbytesArgs { value: None } - } -} - -pub struct hlvecbytesBuilder<'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> hlvecbytesBuilder<'a, 'b, A> { - #[inline] - pub fn add_value(&mut self, value: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>(hlvecbytes::VT_VALUE, value); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> hlvecbytesBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - hlvecbytesBuilder { - 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 hlvecbytes<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("hlvecbytes"); - ds.field("value", &self.value()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvoid_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvoid_generated.rs deleted file mode 100644 index a218c60ba..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvoid_generated.rs +++ /dev/null @@ -1,89 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum hlvoidOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct hlvoid<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for hlvoid<'a> { - type Inner = hlvoid<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> hlvoid<'a> { - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - hlvoid { _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 hlvoidArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = hlvoidBuilder::new(_fbb); - builder.finish() - } -} - -impl flatbuffers::Verifiable for hlvoid<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)?.finish(); - Ok(()) - } -} -pub struct hlvoidArgs {} -impl<'a> Default for hlvoidArgs { - #[inline] - fn default() -> Self { - hlvoidArgs {} - } -} - -pub struct hlvoidBuilder<'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> hlvoidBuilder<'a, 'b, A> { - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> hlvoidBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - hlvoidBuilder { - 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 hlvoid<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("hlvoid"); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_definition_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_definition_generated.rs deleted file mode 100644 index 8ffb6f35e..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_definition_generated.rs +++ /dev/null @@ -1,204 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum HostFunctionDefinitionOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct HostFunctionDefinition<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for HostFunctionDefinition<'a> { - type Inner = HostFunctionDefinition<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> HostFunctionDefinition<'a> { - pub const VT_FUNCTION_NAME: flatbuffers::VOffsetT = 4; - pub const VT_PARAMETERS: flatbuffers::VOffsetT = 6; - pub const VT_RETURN_TYPE: flatbuffers::VOffsetT = 8; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - HostFunctionDefinition { _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 HostFunctionDefinitionArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = HostFunctionDefinitionBuilder::new(_fbb); - if let Some(x) = args.parameters { - builder.add_parameters(x); - } - if let Some(x) = args.function_name { - builder.add_function_name(x); - } - builder.add_return_type(args.return_type); - builder.finish() - } - - #[inline] - pub fn function_name(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>( - HostFunctionDefinition::VT_FUNCTION_NAME, - None, - ) - .unwrap() - } - } - #[inline] - pub fn key_compare_less_than(&self, o: &HostFunctionDefinition) -> bool { - self.function_name() < o.function_name() - } - - #[inline] - pub fn key_compare_with_value(&self, val: &str) -> ::core::cmp::Ordering { - let key = self.function_name(); - key.cmp(val) - } - #[inline] - pub fn parameters(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - HostFunctionDefinition::VT_PARAMETERS, - None, - ) - } - } - #[inline] - pub fn return_type(&self) -> ReturnType { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::( - HostFunctionDefinition::VT_RETURN_TYPE, - Some(ReturnType::hlint), - ) - .unwrap() - } - } -} - -impl flatbuffers::Verifiable for HostFunctionDefinition<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>( - "function_name", - Self::VT_FUNCTION_NAME, - true, - )? - .visit_field::>>( - "parameters", - Self::VT_PARAMETERS, - false, - )? - .visit_field::("return_type", Self::VT_RETURN_TYPE, false)? - .finish(); - Ok(()) - } -} -pub struct HostFunctionDefinitionArgs<'a> { - pub function_name: Option>, - pub parameters: Option>>, - pub return_type: ReturnType, -} -impl<'a> Default for HostFunctionDefinitionArgs<'a> { - #[inline] - fn default() -> Self { - HostFunctionDefinitionArgs { - function_name: None, // required field - parameters: None, - return_type: ReturnType::hlint, - } - } -} - -pub struct HostFunctionDefinitionBuilder<'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> HostFunctionDefinitionBuilder<'a, 'b, A> { - #[inline] - pub fn add_function_name(&mut self, function_name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>( - HostFunctionDefinition::VT_FUNCTION_NAME, - function_name, - ); - } - #[inline] - pub fn add_parameters( - &mut self, - parameters: flatbuffers::WIPOffset>, - ) { - self.fbb_.push_slot_always::>( - HostFunctionDefinition::VT_PARAMETERS, - parameters, - ); - } - #[inline] - pub fn add_return_type(&mut self, return_type: ReturnType) { - self.fbb_.push_slot::( - HostFunctionDefinition::VT_RETURN_TYPE, - return_type, - ReturnType::hlint, - ); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> HostFunctionDefinitionBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - HostFunctionDefinitionBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_ - .required(o, HostFunctionDefinition::VT_FUNCTION_NAME, "function_name"); - flatbuffers::WIPOffset::new(o.value()) - } -} - -impl core::fmt::Debug for HostFunctionDefinition<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("HostFunctionDefinition"); - ds.field("function_name", &self.function_name()); - ds.field("parameters", &self.parameters()); - ds.field("return_type", &self.return_type()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_details_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_details_generated.rs deleted file mode 100644 index 54cf45c73..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_details_generated.rs +++ /dev/null @@ -1,134 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum HostFunctionDetailsOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct HostFunctionDetails<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for HostFunctionDetails<'a> { - type Inner = HostFunctionDetails<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> HostFunctionDetails<'a> { - pub const VT_FUNCTIONS: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - HostFunctionDetails { _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 HostFunctionDetailsArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = HostFunctionDetailsBuilder::new(_fbb); - if let Some(x) = args.functions { - builder.add_functions(x); - } - builder.finish() - } - - #[inline] - pub fn functions( - &self, - ) -> Option>>> - { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(HostFunctionDetails::VT_FUNCTIONS, None) - } - } -} - -impl flatbuffers::Verifiable for HostFunctionDetails<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>, - >>("functions", Self::VT_FUNCTIONS, false)? - .finish(); - Ok(()) - } -} -pub struct HostFunctionDetailsArgs<'a> { - pub functions: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, -} -impl<'a> Default for HostFunctionDetailsArgs<'a> { - #[inline] - fn default() -> Self { - HostFunctionDetailsArgs { functions: None } - } -} - -pub struct HostFunctionDetailsBuilder<'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> HostFunctionDetailsBuilder<'a, 'b, A> { - #[inline] - pub fn add_functions( - &mut self, - functions: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_.push_slot_always::>( - HostFunctionDetails::VT_FUNCTIONS, - functions, - ); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> HostFunctionDetailsBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - HostFunctionDetailsBuilder { - 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 HostFunctionDetails<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("HostFunctionDetails"); - ds.field("functions", &self.functions()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/key_value_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/key_value_generated.rs deleted file mode 100644 index 06516b4a6..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/key_value_generated.rs +++ /dev/null @@ -1,144 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum KeyValueOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct KeyValue<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for KeyValue<'a> { - type Inner = KeyValue<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> KeyValue<'a> { - pub const VT_KEY: flatbuffers::VOffsetT = 4; - pub const VT_VALUE: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - KeyValue { _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 KeyValueArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = KeyValueBuilder::new(_fbb); - if let Some(x) = args.value { - builder.add_value(x); - } - if let Some(x) = args.key { - builder.add_key(x); - } - builder.finish() - } - - #[inline] - pub fn key(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(KeyValue::VT_KEY, None) - .unwrap() - } - } - #[inline] - pub fn value(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(KeyValue::VT_VALUE, None) - .unwrap() - } - } -} - -impl flatbuffers::Verifiable for KeyValue<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>("key", Self::VT_KEY, true)? - .visit_field::>("value", Self::VT_VALUE, true)? - .finish(); - Ok(()) - } -} -pub struct KeyValueArgs<'a> { - pub key: Option>, - pub value: Option>, -} -impl<'a> Default for KeyValueArgs<'a> { - #[inline] - fn default() -> Self { - KeyValueArgs { - key: None, // required field - value: None, // required field - } - } -} - -pub struct KeyValueBuilder<'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> KeyValueBuilder<'a, 'b, A> { - #[inline] - pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(KeyValue::VT_KEY, key); - } - #[inline] - pub fn add_value(&mut self, value: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(KeyValue::VT_VALUE, value); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> KeyValueBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - KeyValueBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, KeyValue::VT_KEY, "key"); - self.fbb_.required(o, KeyValue::VT_VALUE, "value"); - flatbuffers::WIPOffset::new(o.value()) - } -} - -impl core::fmt::Debug for KeyValue<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("KeyValue"); - ds.field("key", &self.key()); - ds.field("value", &self.value()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/log_event_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/log_event_type_generated.rs deleted file mode 100644 index c78c37a59..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/log_event_type_generated.rs +++ /dev/null @@ -1,195 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum LogEventTypeOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct LogEventType<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for LogEventType<'a> { - type Inner = LogEventType<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> LogEventType<'a> { - pub const VT_PARENT_ID: flatbuffers::VOffsetT = 4; - pub const VT_NAME: flatbuffers::VOffsetT = 6; - pub const VT_TSC: flatbuffers::VOffsetT = 8; - pub const VT_FIELDS: flatbuffers::VOffsetT = 10; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - LogEventType { _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 LogEventTypeArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = LogEventTypeBuilder::new(_fbb); - builder.add_tsc(args.tsc); - builder.add_parent_id(args.parent_id); - if let Some(x) = args.fields { - builder.add_fields(x); - } - if let Some(x) = args.name { - builder.add_name(x); - } - builder.finish() - } - - #[inline] - pub fn parent_id(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(LogEventType::VT_PARENT_ID, Some(0)) - .unwrap() - } - } - #[inline] - pub fn name(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(LogEventType::VT_NAME, None) - .unwrap() - } - } - #[inline] - pub fn tsc(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(LogEventType::VT_TSC, Some(0)).unwrap() } - } - #[inline] - pub fn fields( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(LogEventType::VT_FIELDS, None) - } - } -} - -impl flatbuffers::Verifiable for LogEventType<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("parent_id", Self::VT_PARENT_ID, false)? - .visit_field::>("name", Self::VT_NAME, true)? - .visit_field::("tsc", Self::VT_TSC, false)? - .visit_field::>, - >>("fields", Self::VT_FIELDS, false)? - .finish(); - Ok(()) - } -} -pub struct LogEventTypeArgs<'a> { - pub parent_id: u64, - pub name: Option>, - pub tsc: u64, - pub fields: Option< - flatbuffers::WIPOffset>>>, - >, -} -impl<'a> Default for LogEventTypeArgs<'a> { - #[inline] - fn default() -> Self { - LogEventTypeArgs { - parent_id: 0, - name: None, // required field - tsc: 0, - fields: None, - } - } -} - -pub struct LogEventTypeBuilder<'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> LogEventTypeBuilder<'a, 'b, A> { - #[inline] - pub fn add_parent_id(&mut self, parent_id: u64) { - self.fbb_ - .push_slot::(LogEventType::VT_PARENT_ID, parent_id, 0); - } - #[inline] - pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(LogEventType::VT_NAME, name); - } - #[inline] - pub fn add_tsc(&mut self, tsc: u64) { - self.fbb_.push_slot::(LogEventType::VT_TSC, tsc, 0); - } - #[inline] - pub fn add_fields( - &mut self, - fields: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(LogEventType::VT_FIELDS, fields); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> LogEventTypeBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - LogEventTypeBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, LogEventType::VT_NAME, "name"); - flatbuffers::WIPOffset::new(o.value()) - } -} - -impl core::fmt::Debug for LogEventType<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("LogEventType"); - ds.field("parent_id", &self.parent_id()); - ds.field("name", &self.name()); - ds.field("tsc", &self.tsc()); - ds.field("fields", &self.fields()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/log_level_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/log_level_generated.rs deleted file mode 100644 index 6fb5ce2c6..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/log_level_generated.rs +++ /dev/null @@ -1,129 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MIN_LOG_LEVEL: u8 = 0; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MAX_LOG_LEVEL: u8 = 6; -#[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_LOG_LEVEL: [LogLevel; 7] = [ - LogLevel::Trace, - LogLevel::Debug, - LogLevel::Information, - LogLevel::Warning, - LogLevel::Error, - LogLevel::Critical, - LogLevel::None, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct LogLevel(pub u8); -#[allow(non_upper_case_globals)] -impl LogLevel { - pub const Trace: Self = Self(0); - pub const Debug: Self = Self(1); - pub const Information: Self = Self(2); - pub const Warning: Self = Self(3); - pub const Error: Self = Self(4); - pub const Critical: Self = Self(5); - pub const None: Self = Self(6); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 6; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::Trace, - Self::Debug, - Self::Information, - Self::Warning, - Self::Error, - Self::Critical, - Self::None, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::Trace => Some("Trace"), - Self::Debug => Some("Debug"), - Self::Information => Some("Information"), - Self::Warning => Some("Warning"), - Self::Error => Some("Error"), - Self::Critical => Some("Critical"), - Self::None => Some("None"), - _ => None, - } - } -} -impl core::fmt::Debug for LogLevel { - 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 LogLevel { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl flatbuffers::Push for LogLevel { - type Output = LogLevel; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { - flatbuffers::emplace_scalar::(dst, self.0); - } - } -} - -impl flatbuffers::EndianScalar for LogLevel { - 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 LogLevel { - #[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 LogLevel {} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/open_span_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/open_span_type_generated.rs deleted file mode 100644 index d5d9ac8ef..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/open_span_type_generated.rs +++ /dev/null @@ -1,235 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum OpenSpanTypeOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct OpenSpanType<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for OpenSpanType<'a> { - type Inner = OpenSpanType<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> OpenSpanType<'a> { - pub const VT_ID: flatbuffers::VOffsetT = 4; - pub const VT_PARENT: flatbuffers::VOffsetT = 6; - pub const VT_NAME: flatbuffers::VOffsetT = 8; - pub const VT_TARGET: flatbuffers::VOffsetT = 10; - pub const VT_TSC: flatbuffers::VOffsetT = 12; - pub const VT_FIELDS: flatbuffers::VOffsetT = 14; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - OpenSpanType { _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 OpenSpanTypeArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = OpenSpanTypeBuilder::new(_fbb); - builder.add_tsc(args.tsc); - if let Some(x) = args.parent { - builder.add_parent(x); - } - builder.add_id(args.id); - if let Some(x) = args.fields { - builder.add_fields(x); - } - if let Some(x) = args.target { - builder.add_target(x); - } - if let Some(x) = args.name { - builder.add_name(x); - } - builder.finish() - } - - #[inline] - pub fn id(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(OpenSpanType::VT_ID, Some(0)).unwrap() } - } - #[inline] - pub fn parent(&self) -> Option { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(OpenSpanType::VT_PARENT, None) } - } - #[inline] - pub fn name(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(OpenSpanType::VT_NAME, None) - .unwrap() - } - } - #[inline] - pub fn target(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(OpenSpanType::VT_TARGET, None) - .unwrap() - } - } - #[inline] - pub fn tsc(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(OpenSpanType::VT_TSC, Some(0)).unwrap() } - } - #[inline] - pub fn fields( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(OpenSpanType::VT_FIELDS, None) - } - } -} - -impl flatbuffers::Verifiable for OpenSpanType<'_> { - #[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::("parent", Self::VT_PARENT, false)? - .visit_field::>("name", Self::VT_NAME, true)? - .visit_field::>("target", Self::VT_TARGET, true)? - .visit_field::("tsc", Self::VT_TSC, false)? - .visit_field::>, - >>("fields", Self::VT_FIELDS, false)? - .finish(); - Ok(()) - } -} -pub struct OpenSpanTypeArgs<'a> { - pub id: u64, - pub parent: Option, - pub name: Option>, - pub target: Option>, - pub tsc: u64, - pub fields: Option< - flatbuffers::WIPOffset>>>, - >, -} -impl<'a> Default for OpenSpanTypeArgs<'a> { - #[inline] - fn default() -> Self { - OpenSpanTypeArgs { - id: 0, - parent: None, - name: None, // required field - target: None, // required field - tsc: 0, - fields: None, - } - } -} - -pub struct OpenSpanTypeBuilder<'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> OpenSpanTypeBuilder<'a, 'b, A> { - #[inline] - pub fn add_id(&mut self, id: u64) { - self.fbb_.push_slot::(OpenSpanType::VT_ID, id, 0); - } - #[inline] - pub fn add_parent(&mut self, parent: u64) { - self.fbb_ - .push_slot_always::(OpenSpanType::VT_PARENT, parent); - } - #[inline] - pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(OpenSpanType::VT_NAME, name); - } - #[inline] - pub fn add_target(&mut self, target: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(OpenSpanType::VT_TARGET, target); - } - #[inline] - pub fn add_tsc(&mut self, tsc: u64) { - self.fbb_.push_slot::(OpenSpanType::VT_TSC, tsc, 0); - } - #[inline] - pub fn add_fields( - &mut self, - fields: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(OpenSpanType::VT_FIELDS, fields); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> OpenSpanTypeBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - OpenSpanTypeBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, OpenSpanType::VT_NAME, "name"); - self.fbb_.required(o, OpenSpanType::VT_TARGET, "target"); - flatbuffers::WIPOffset::new(o.value()) - } -} - -impl core::fmt::Debug for OpenSpanType<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("OpenSpanType"); - ds.field("id", &self.id()); - ds.field("parent", &self.parent()); - ds.field("name", &self.name()); - ds.field("target", &self.target()); - ds.field("tsc", &self.tsc()); - ds.field("fields", &self.fields()); - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_generated.rs deleted file mode 100644 index b0e803ec5..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_generated.rs +++ /dev/null @@ -1,420 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum ParameterOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Parameter<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for Parameter<'a> { - type Inner = Parameter<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> Parameter<'a> { - pub const VT_VALUE_TYPE: flatbuffers::VOffsetT = 4; - pub const VT_VALUE: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Parameter { _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 ParameterArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = ParameterBuilder::new(_fbb); - if let Some(x) = args.value { - builder.add_value(x); - } - builder.add_value_type(args.value_type); - builder.finish() - } - - #[inline] - pub fn value_type(&self) -> ParameterValue { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Parameter::VT_VALUE_TYPE, Some(ParameterValue::NONE)) - .unwrap() - } - } - #[inline] - pub fn value(&self) -> flatbuffers::Table<'a> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - Parameter::VT_VALUE, - None, - ) - .unwrap() - } - } - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hlint(&self) -> Option> { - if self.value_type() == ParameterValue::hlint { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hlint::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hluint(&self) -> Option> { - if self.value_type() == ParameterValue::hluint { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hluint::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hllong(&self) -> Option> { - if self.value_type() == ParameterValue::hllong { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hllong::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hlulong(&self) -> Option> { - if self.value_type() == ParameterValue::hlulong { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hlulong::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hlfloat(&self) -> Option> { - if self.value_type() == ParameterValue::hlfloat { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hlfloat::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hldouble(&self) -> Option> { - if self.value_type() == ParameterValue::hldouble { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hldouble::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hlstring(&self) -> Option> { - if self.value_type() == ParameterValue::hlstring { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hlstring::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hlbool(&self) -> Option> { - if self.value_type() == ParameterValue::hlbool { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hlbool::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hlvecbytes(&self) -> Option> { - if self.value_type() == ParameterValue::hlvecbytes { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hlvecbytes::init_from_table(u) }) - } else { - None - } - } -} - -impl flatbuffers::Verifiable for Parameter<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_union::( - "value_type", - Self::VT_VALUE_TYPE, - "value", - Self::VT_VALUE, - true, - |key, v, pos| match key { - ParameterValue::hlint => v - .verify_union_variant::>( - "ParameterValue::hlint", - pos, - ), - ParameterValue::hluint => v - .verify_union_variant::>( - "ParameterValue::hluint", - pos, - ), - ParameterValue::hllong => v - .verify_union_variant::>( - "ParameterValue::hllong", - pos, - ), - ParameterValue::hlulong => v - .verify_union_variant::>( - "ParameterValue::hlulong", - pos, - ), - ParameterValue::hlfloat => v - .verify_union_variant::>( - "ParameterValue::hlfloat", - pos, - ), - ParameterValue::hldouble => v - .verify_union_variant::>( - "ParameterValue::hldouble", - pos, - ), - ParameterValue::hlstring => v - .verify_union_variant::>( - "ParameterValue::hlstring", - pos, - ), - ParameterValue::hlbool => v - .verify_union_variant::>( - "ParameterValue::hlbool", - pos, - ), - ParameterValue::hlvecbytes => v - .verify_union_variant::>( - "ParameterValue::hlvecbytes", - pos, - ), - _ => Ok(()), - }, - )? - .finish(); - Ok(()) - } -} -pub struct ParameterArgs { - pub value_type: ParameterValue, - pub value: Option>, -} -impl<'a> Default for ParameterArgs { - #[inline] - fn default() -> Self { - ParameterArgs { - value_type: ParameterValue::NONE, - value: None, // required field - } - } -} - -pub struct ParameterBuilder<'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> ParameterBuilder<'a, 'b, A> { - #[inline] - pub fn add_value_type(&mut self, value_type: ParameterValue) { - self.fbb_.push_slot::( - Parameter::VT_VALUE_TYPE, - value_type, - ParameterValue::NONE, - ); - } - #[inline] - pub fn add_value(&mut self, value: flatbuffers::WIPOffset) { - self.fbb_ - .push_slot_always::>(Parameter::VT_VALUE, value); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ParameterBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - ParameterBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, Parameter::VT_VALUE, "value"); - flatbuffers::WIPOffset::new(o.value()) - } -} - -impl core::fmt::Debug for Parameter<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Parameter"); - ds.field("value_type", &self.value_type()); - match self.value_type() { - ParameterValue::hlint => { - if let Some(x) = self.value_as_hlint() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ParameterValue::hluint => { - if let Some(x) = self.value_as_hluint() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ParameterValue::hllong => { - if let Some(x) = self.value_as_hllong() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ParameterValue::hlulong => { - if let Some(x) = self.value_as_hlulong() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ParameterValue::hlfloat => { - if let Some(x) = self.value_as_hlfloat() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ParameterValue::hldouble => { - if let Some(x) = self.value_as_hldouble() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ParameterValue::hlstring => { - if let Some(x) = self.value_as_hlstring() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ParameterValue::hlbool => { - if let Some(x) = self.value_as_hlbool() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ParameterValue::hlvecbytes => { - if let Some(x) = self.value_as_hlvecbytes() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - _ => { - let x: Option<()> = None; - ds.field("value", &x) - } - }; - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_type_generated.rs deleted file mode 100644 index cf46560b1..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_type_generated.rs +++ /dev/null @@ -1,137 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MIN_PARAMETER_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_PARAMETER_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_PARAMETER_TYPE: [ParameterType; 9] = [ - ParameterType::hlint, - ParameterType::hluint, - ParameterType::hllong, - ParameterType::hlulong, - ParameterType::hlfloat, - ParameterType::hldouble, - ParameterType::hlstring, - ParameterType::hlbool, - ParameterType::hlvecbytes, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct ParameterType(pub u8); -#[allow(non_upper_case_globals)] -impl ParameterType { - pub const hlint: Self = Self(0); - pub const hluint: Self = Self(1); - pub const hllong: Self = Self(2); - pub const hlulong: Self = Self(3); - pub const hlfloat: Self = Self(4); - pub const hldouble: Self = Self(5); - pub const hlstring: Self = Self(6); - pub const hlbool: Self = Self(7); - pub const hlvecbytes: Self = Self(8); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 8; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::hlint, - Self::hluint, - Self::hllong, - Self::hlulong, - Self::hlfloat, - Self::hldouble, - Self::hlstring, - Self::hlbool, - Self::hlvecbytes, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::hlint => Some("hlint"), - Self::hluint => Some("hluint"), - Self::hllong => Some("hllong"), - Self::hlulong => Some("hlulong"), - Self::hlfloat => Some("hlfloat"), - Self::hldouble => Some("hldouble"), - Self::hlstring => Some("hlstring"), - Self::hlbool => Some("hlbool"), - Self::hlvecbytes => Some("hlvecbytes"), - _ => None, - } - } -} -impl core::fmt::Debug for ParameterType { - 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 ParameterType { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl flatbuffers::Push for ParameterType { - type Output = ParameterType; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { - flatbuffers::emplace_scalar::(dst, self.0); - } - } -} - -impl flatbuffers::EndianScalar for ParameterType { - 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 ParameterType { - #[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 ParameterType {} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_value_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_value_generated.rs deleted file mode 100644 index 8113df5fc..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_value_generated.rs +++ /dev/null @@ -1,142 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MIN_PARAMETER_VALUE: u8 = 0; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MAX_PARAMETER_VALUE: u8 = 9; -#[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_PARAMETER_VALUE: [ParameterValue; 10] = [ - ParameterValue::NONE, - ParameterValue::hlint, - ParameterValue::hluint, - ParameterValue::hllong, - ParameterValue::hlulong, - ParameterValue::hlfloat, - ParameterValue::hldouble, - ParameterValue::hlstring, - ParameterValue::hlbool, - ParameterValue::hlvecbytes, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct ParameterValue(pub u8); -#[allow(non_upper_case_globals)] -impl ParameterValue { - pub const NONE: Self = Self(0); - pub const hlint: Self = Self(1); - pub const hluint: Self = Self(2); - pub const hllong: Self = Self(3); - pub const hlulong: Self = Self(4); - pub const hlfloat: Self = Self(5); - pub const hldouble: Self = Self(6); - pub const hlstring: Self = Self(7); - pub const hlbool: Self = Self(8); - pub const hlvecbytes: Self = Self(9); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 9; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::NONE, - Self::hlint, - Self::hluint, - Self::hllong, - Self::hlulong, - Self::hlfloat, - Self::hldouble, - Self::hlstring, - Self::hlbool, - Self::hlvecbytes, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::NONE => Some("NONE"), - Self::hlint => Some("hlint"), - Self::hluint => Some("hluint"), - Self::hllong => Some("hllong"), - Self::hlulong => Some("hlulong"), - Self::hlfloat => Some("hlfloat"), - Self::hldouble => Some("hldouble"), - Self::hlstring => Some("hlstring"), - Self::hlbool => Some("hlbool"), - Self::hlvecbytes => Some("hlvecbytes"), - _ => None, - } - } -} -impl core::fmt::Debug for ParameterValue { - 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 ParameterValue { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl flatbuffers::Push for ParameterValue { - type Output = ParameterValue; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { - flatbuffers::emplace_scalar::(dst, self.0); - } - } -} - -impl flatbuffers::EndianScalar for ParameterValue { - 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 ParameterValue { - #[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 ParameterValue {} -pub struct ParameterValueUnionTableOffset {} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_type_generated.rs deleted file mode 100644 index 913b1fe78..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_type_generated.rs +++ /dev/null @@ -1,141 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MIN_RETURN_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_RETURN_TYPE: u8 = 9; -#[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_RETURN_TYPE: [ReturnType; 10] = [ - ReturnType::hlint, - ReturnType::hluint, - ReturnType::hllong, - ReturnType::hlulong, - ReturnType::hlfloat, - ReturnType::hldouble, - ReturnType::hlstring, - ReturnType::hlbool, - ReturnType::hlvoid, - ReturnType::hlsizeprefixedbuffer, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct ReturnType(pub u8); -#[allow(non_upper_case_globals)] -impl ReturnType { - pub const hlint: Self = Self(0); - pub const hluint: Self = Self(1); - pub const hllong: Self = Self(2); - pub const hlulong: Self = Self(3); - pub const hlfloat: Self = Self(4); - pub const hldouble: Self = Self(5); - pub const hlstring: Self = Self(6); - pub const hlbool: Self = Self(7); - pub const hlvoid: Self = Self(8); - pub const hlsizeprefixedbuffer: Self = Self(9); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 9; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::hlint, - Self::hluint, - Self::hllong, - Self::hlulong, - Self::hlfloat, - Self::hldouble, - Self::hlstring, - Self::hlbool, - Self::hlvoid, - Self::hlsizeprefixedbuffer, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::hlint => Some("hlint"), - Self::hluint => Some("hluint"), - Self::hllong => Some("hllong"), - Self::hlulong => Some("hlulong"), - Self::hlfloat => Some("hlfloat"), - Self::hldouble => Some("hldouble"), - Self::hlstring => Some("hlstring"), - Self::hlbool => Some("hlbool"), - Self::hlvoid => Some("hlvoid"), - Self::hlsizeprefixedbuffer => Some("hlsizeprefixedbuffer"), - _ => None, - } - } -} -impl core::fmt::Debug for ReturnType { - 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 ReturnType { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl flatbuffers::Push for ReturnType { - type Output = ReturnType; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { - flatbuffers::emplace_scalar::(dst, self.0); - } - } -} - -impl flatbuffers::EndianScalar for ReturnType { - 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 ReturnType { - #[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 ReturnType {} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_value_box_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_value_box_generated.rs deleted file mode 100644 index cecd8b6c1..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_value_box_generated.rs +++ /dev/null @@ -1,451 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -pub enum ReturnValueBoxOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct ReturnValueBox<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for ReturnValueBox<'a> { - type Inner = ReturnValueBox<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: unsafe { flatbuffers::Table::new(buf, loc) }, - } - } -} - -impl<'a> ReturnValueBox<'a> { - pub const VT_VALUE_TYPE: flatbuffers::VOffsetT = 4; - pub const VT_VALUE: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - ReturnValueBox { _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 ReturnValueBoxArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = ReturnValueBoxBuilder::new(_fbb); - if let Some(x) = args.value { - builder.add_value(x); - } - builder.add_value_type(args.value_type); - builder.finish() - } - - #[inline] - pub fn value_type(&self) -> ReturnValue { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(ReturnValueBox::VT_VALUE_TYPE, Some(ReturnValue::NONE)) - .unwrap() - } - } - #[inline] - pub fn value(&self) -> flatbuffers::Table<'a> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>( - ReturnValueBox::VT_VALUE, - None, - ) - .unwrap() - } - } - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hlint(&self) -> Option> { - if self.value_type() == ReturnValue::hlint { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hlint::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hluint(&self) -> Option> { - if self.value_type() == ReturnValue::hluint { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hluint::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hllong(&self) -> Option> { - if self.value_type() == ReturnValue::hllong { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hllong::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hlulong(&self) -> Option> { - if self.value_type() == ReturnValue::hlulong { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hlulong::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hlfloat(&self) -> Option> { - if self.value_type() == ReturnValue::hlfloat { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hlfloat::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hldouble(&self) -> Option> { - if self.value_type() == ReturnValue::hldouble { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hldouble::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hlstring(&self) -> Option> { - if self.value_type() == ReturnValue::hlstring { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hlstring::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hlbool(&self) -> Option> { - if self.value_type() == ReturnValue::hlbool { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hlbool::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hlvoid(&self) -> Option> { - if self.value_type() == ReturnValue::hlvoid { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hlvoid::init_from_table(u) }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn value_as_hlsizeprefixedbuffer(&self) -> Option> { - if self.value_type() == ReturnValue::hlsizeprefixedbuffer { - let u = self.value(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - Some(unsafe { hlsizeprefixedbuffer::init_from_table(u) }) - } else { - None - } - } -} - -impl flatbuffers::Verifiable for ReturnValueBox<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_union::( - "value_type", - Self::VT_VALUE_TYPE, - "value", - Self::VT_VALUE, - true, - |key, v, pos| match key { - ReturnValue::hlint => v - .verify_union_variant::>( - "ReturnValue::hlint", - pos, - ), - ReturnValue::hluint => v - .verify_union_variant::>( - "ReturnValue::hluint", - pos, - ), - ReturnValue::hllong => v - .verify_union_variant::>( - "ReturnValue::hllong", - pos, - ), - ReturnValue::hlulong => v - .verify_union_variant::>( - "ReturnValue::hlulong", - pos, - ), - ReturnValue::hlfloat => v - .verify_union_variant::>( - "ReturnValue::hlfloat", - pos, - ), - ReturnValue::hldouble => v - .verify_union_variant::>( - "ReturnValue::hldouble", - pos, - ), - ReturnValue::hlstring => v - .verify_union_variant::>( - "ReturnValue::hlstring", - pos, - ), - ReturnValue::hlbool => v - .verify_union_variant::>( - "ReturnValue::hlbool", - pos, - ), - ReturnValue::hlvoid => v - .verify_union_variant::>( - "ReturnValue::hlvoid", - pos, - ), - ReturnValue::hlsizeprefixedbuffer => v - .verify_union_variant::>( - "ReturnValue::hlsizeprefixedbuffer", - pos, - ), - _ => Ok(()), - }, - )? - .finish(); - Ok(()) - } -} -pub struct ReturnValueBoxArgs { - pub value_type: ReturnValue, - pub value: Option>, -} -impl<'a> Default for ReturnValueBoxArgs { - #[inline] - fn default() -> Self { - ReturnValueBoxArgs { - value_type: ReturnValue::NONE, - value: None, // required field - } - } -} - -pub struct ReturnValueBoxBuilder<'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> ReturnValueBoxBuilder<'a, 'b, A> { - #[inline] - pub fn add_value_type(&mut self, value_type: ReturnValue) { - self.fbb_.push_slot::( - ReturnValueBox::VT_VALUE_TYPE, - value_type, - ReturnValue::NONE, - ); - } - #[inline] - pub fn add_value(&mut self, value: flatbuffers::WIPOffset) { - self.fbb_ - .push_slot_always::>(ReturnValueBox::VT_VALUE, value); - } - #[inline] - pub fn new( - _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - ) -> ReturnValueBoxBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - ReturnValueBoxBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, ReturnValueBox::VT_VALUE, "value"); - flatbuffers::WIPOffset::new(o.value()) - } -} - -impl core::fmt::Debug for ReturnValueBox<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("ReturnValueBox"); - ds.field("value_type", &self.value_type()); - match self.value_type() { - ReturnValue::hlint => { - if let Some(x) = self.value_as_hlint() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ReturnValue::hluint => { - if let Some(x) = self.value_as_hluint() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ReturnValue::hllong => { - if let Some(x) = self.value_as_hllong() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ReturnValue::hlulong => { - if let Some(x) = self.value_as_hlulong() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ReturnValue::hlfloat => { - if let Some(x) = self.value_as_hlfloat() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ReturnValue::hldouble => { - if let Some(x) = self.value_as_hldouble() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ReturnValue::hlstring => { - if let Some(x) = self.value_as_hlstring() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ReturnValue::hlbool => { - if let Some(x) = self.value_as_hlbool() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ReturnValue::hlvoid => { - if let Some(x) = self.value_as_hlvoid() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - ReturnValue::hlsizeprefixedbuffer => { - if let Some(x) = self.value_as_hlsizeprefixedbuffer() { - ds.field("value", &x) - } else { - ds.field( - "value", - &"InvalidFlatbuffer: Union discriminant does not match value.", - ) - } - } - _ => { - let x: Option<()> = None; - ds.field("value", &x) - } - }; - ds.finish() - } -} diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_value_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_value_generated.rs deleted file mode 100644 index d13c73623..000000000 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_value_generated.rs +++ /dev/null @@ -1,146 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; -extern crate flatbuffers; -use alloc::boxed::Box; -use alloc::string::{String, ToString}; -use alloc::vec::Vec; -use core::cmp::Ordering; -use core::mem; - -use self::flatbuffers::{EndianScalar, Follow}; -use super::*; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MIN_RETURN_VALUE: u8 = 0; -#[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." -)] -pub const ENUM_MAX_RETURN_VALUE: u8 = 10; -#[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_RETURN_VALUE: [ReturnValue; 11] = [ - ReturnValue::NONE, - ReturnValue::hlint, - ReturnValue::hluint, - ReturnValue::hllong, - ReturnValue::hlulong, - ReturnValue::hlfloat, - ReturnValue::hldouble, - ReturnValue::hlstring, - ReturnValue::hlbool, - ReturnValue::hlvoid, - ReturnValue::hlsizeprefixedbuffer, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct ReturnValue(pub u8); -#[allow(non_upper_case_globals)] -impl ReturnValue { - pub const NONE: Self = Self(0); - pub const hlint: Self = Self(1); - pub const hluint: Self = Self(2); - pub const hllong: Self = Self(3); - pub const hlulong: Self = Self(4); - pub const hlfloat: Self = Self(5); - pub const hldouble: Self = Self(6); - pub const hlstring: Self = Self(7); - pub const hlbool: Self = Self(8); - pub const hlvoid: Self = Self(9); - pub const hlsizeprefixedbuffer: Self = Self(10); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 10; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::NONE, - Self::hlint, - Self::hluint, - Self::hllong, - Self::hlulong, - Self::hlfloat, - Self::hldouble, - Self::hlstring, - Self::hlbool, - Self::hlvoid, - Self::hlsizeprefixedbuffer, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::NONE => Some("NONE"), - Self::hlint => Some("hlint"), - Self::hluint => Some("hluint"), - Self::hllong => Some("hllong"), - Self::hlulong => Some("hlulong"), - Self::hlfloat => Some("hlfloat"), - Self::hldouble => Some("hldouble"), - Self::hlstring => Some("hlstring"), - Self::hlbool => Some("hlbool"), - Self::hlvoid => Some("hlvoid"), - Self::hlsizeprefixedbuffer => Some("hlsizeprefixedbuffer"), - _ => None, - } - } -} -impl core::fmt::Debug for ReturnValue { - 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 ReturnValue { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl flatbuffers::Push for ReturnValue { - type Output = ReturnValue; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { - flatbuffers::emplace_scalar::(dst, self.0); - } - } -} - -impl flatbuffers::EndianScalar for ReturnValue { - 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 ReturnValue { - #[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 ReturnValue {} -pub struct ReturnValueUnionTableOffset {} diff --git a/src/hyperlight_common/src/flatbuffers/mod.rs b/src/hyperlight_common/src/flatbuffers/mod.rs deleted file mode 100644 index 184260572..000000000 --- a/src/hyperlight_common/src/flatbuffers/mod.rs +++ /dev/null @@ -1,78 +0,0 @@ -// Automatically generated by the Flatbuffers compiler. Do not modify. -// @generated -pub mod hyperlight { - use super::*; - pub mod generated { - use super::*; - mod parameter_value_generated; - pub use self::parameter_value_generated::*; - mod parameter_type_generated; - pub use self::parameter_type_generated::*; - mod return_type_generated; - pub use self::return_type_generated::*; - mod return_value_generated; - pub use self::return_value_generated::*; - mod error_code_generated; - pub use self::error_code_generated::*; - mod function_call_result_type_generated; - pub use self::function_call_result_type_generated::*; - mod function_call_type_generated; - pub use self::function_call_type_generated::*; - mod log_level_generated; - pub use self::log_level_generated::*; - mod guest_event_type_generated; - pub use self::guest_event_type_generated::*; - mod hlint_generated; - pub use self::hlint_generated::*; - mod hluint_generated; - pub use self::hluint_generated::*; - mod hllong_generated; - pub use self::hllong_generated::*; - mod hlulong_generated; - pub use self::hlulong_generated::*; - mod hlfloat_generated; - pub use self::hlfloat_generated::*; - mod hldouble_generated; - pub use self::hldouble_generated::*; - mod hlstring_generated; - pub use self::hlstring_generated::*; - mod hlbool_generated; - pub use self::hlbool_generated::*; - mod hlvecbytes_generated; - pub use self::hlvecbytes_generated::*; - mod hlsizeprefixedbuffer_generated; - pub use self::hlsizeprefixedbuffer_generated::*; - mod hlvoid_generated; - pub use self::hlvoid_generated::*; - mod guest_error_generated; - pub use self::guest_error_generated::*; - mod return_value_box_generated; - pub use self::return_value_box_generated::*; - mod function_call_result_generated; - pub use self::function_call_result_generated::*; - mod parameter_generated; - pub use self::parameter_generated::*; - mod function_call_generated; - pub use self::function_call_generated::*; - mod guest_log_data_generated; - pub use self::guest_log_data_generated::*; - mod key_value_generated; - pub use self::key_value_generated::*; - mod open_span_type_generated; - pub use self::open_span_type_generated::*; - mod close_span_type_generated; - pub use self::close_span_type_generated::*; - mod log_event_type_generated; - pub use self::log_event_type_generated::*; - mod edit_span_type_generated; - pub use self::edit_span_type_generated::*; - mod guest_start_type_generated; - pub use self::guest_start_type_generated::*; - mod guest_event_envelope_type_generated; - pub use self::guest_event_envelope_type_generated::*; - mod host_function_definition_generated; - pub use self::host_function_definition_generated::*; - mod host_function_details_generated; - pub use self::host_function_details_generated::*; - } // generated -} // hyperlight diff --git a/src/hyperlight_common/src/lib.rs b/src/hyperlight_common/src/lib.rs index da9294c19..b6b547fb8 100644 --- a/src/hyperlight_common/src/lib.rs +++ b/src/hyperlight_common/src/lib.rs @@ -23,10 +23,7 @@ limitations under the License. extern crate alloc; pub mod flatbuffer_wrappers; -/// cbindgen:ignore -/// FlatBuffers-related utilities and (mostly) generated code -#[allow(clippy::all, warnings)] -mod flatbuffers; + // cbindgen:ignore pub mod layout; From aa61e847bf2c25234471de7cfdd0802c1200a5e1 Mon Sep 17 00:00:00 2001 From: Jorge Prendes Date: Thu, 8 Jan 2026 12:39:01 +0000 Subject: [PATCH 3/5] remove flatbuffer schema Signed-off-by: Jorge Prendes --- src/schema/all.fbs | 8 -- src/schema/function_call.fbs | 33 ------- src/schema/function_call_result.fbs | 21 ---- src/schema/function_types.fbs | 124 ------------------------ src/schema/guest_error.fbs | 28 ------ src/schema/guest_log_data.fbs | 22 ----- src/schema/guest_trace_data.fbs | 51 ---------- src/schema/host_function_definition.fbs | 11 --- src/schema/host_function_details.fbs | 9 -- 9 files changed, 307 deletions(-) delete mode 100644 src/schema/all.fbs delete mode 100644 src/schema/function_call.fbs delete mode 100644 src/schema/function_call_result.fbs delete mode 100644 src/schema/function_types.fbs delete mode 100644 src/schema/guest_error.fbs delete mode 100644 src/schema/guest_log_data.fbs delete mode 100644 src/schema/guest_trace_data.fbs delete mode 100644 src/schema/host_function_definition.fbs delete mode 100644 src/schema/host_function_details.fbs diff --git a/src/schema/all.fbs b/src/schema/all.fbs deleted file mode 100644 index 07cebfd8e..000000000 --- a/src/schema/all.fbs +++ /dev/null @@ -1,8 +0,0 @@ -include "function_types.fbs"; -include "function_call_result.fbs"; -include "function_call.fbs"; -include "guest_error.fbs"; -include "guest_log_data.fbs"; -include "guest_trace_data.fbs"; -include "host_function_definition.fbs"; -include "host_function_details.fbs"; diff --git a/src/schema/function_call.fbs b/src/schema/function_call.fbs deleted file mode 100644 index 9ad0d8ddf..000000000 --- a/src/schema/function_call.fbs +++ /dev/null @@ -1,33 +0,0 @@ -include "function_types.fbs"; - -namespace Hyperlight.Generated; - -enum FunctionCallType : ubyte { - // none is invalid, its the default, its only here to ensure that the type is explicitly set to guest or host as none should fail validation if a buffer using it is written to memory - none, - guest, - host, -} - -// Flatbuffers rust generator doesn't support vectors of unions so we have to wrap them in a table -// see https://github.com/google/flatbuffers/issues/5024 - -table Parameter { - value:ParameterValue(required); -} - -table FunctionCall { - function_name:string(required, key); - parameters:[Parameter]; - function_call_type:FunctionCallType; - // For dynamic calls such as WASM functions we need to know the expected return type - // as these functions are not registered in the guest then there is no way of knowing what the return type is expected to be - // we could register all the WASM functions in the guest by examining the WASM module - // but even if we did this we would still not know the return type of the function as WASM metadata does not contain this information - // so we have to rely on the host to tell us what the return type is - // we can also use this to validate what the host expects where we have a statically registered function. - // If we ultimately adopt WIT for IDL then we might not need this any longer - expected_return_type:ReturnType; -} - -root_type FunctionCall; \ No newline at end of file diff --git a/src/schema/function_call_result.fbs b/src/schema/function_call_result.fbs deleted file mode 100644 index 53ea52b25..000000000 --- a/src/schema/function_call_result.fbs +++ /dev/null @@ -1,21 +0,0 @@ -include "function_types.fbs"; -include "guest_error.fbs"; - -namespace Hyperlight.Generated; - -// Wrapper so ReturnValue (a union) can be a single union variant -table ReturnValueBox { - value: ReturnValue (required); -} - -// Result-like union -union FunctionCallResultType { - ReturnValueBox, - GuestError -} - -table FunctionCallResult { - result: FunctionCallResultType (required); -} - -root_type FunctionCallResult; \ No newline at end of file diff --git a/src/schema/function_types.fbs b/src/schema/function_types.fbs deleted file mode 100644 index d5c209ff6..000000000 --- a/src/schema/function_types.fbs +++ /dev/null @@ -1,124 +0,0 @@ -namespace Hyperlight.Generated; - -// the following tables are used to hold the values of the parameters and return values of functions -// they are named with hl prefix to avoid reserved word clashes in generated code - -// hlint is a 32 bit signed integer - -table hlint { - value:int; -} - -// hluint is a 32 bit unsigned integer - -table hluint { - value:uint; -} - -// hllong is a 64 bit signed integer - -table hllong { - value:long; -} - -// hlulong is a 64 bit unsigned integer - -table hlulong { - value:ulong; -} - -// hlfloat is 32-bit float - -table hlfloat { - value:float; -} - -// hldouble is 64-bit float - -table hldouble { - value:double; -} - -// hlstring is a UTF8 encoded string - -table hlstring{ - value:string; -} - -// hlbool is a C99 boolean - -table hlbool { - value:bool; -} - -// hlvecbytes is a vector of bytes - -table hlvecbytes { - value:[ubyte]; -} - -// hlsizeprefixedbuffer is a vector of bytes prefixed with a 32 bit integer - -table hlsizeprefixedbuffer { - size:int; - value:[ubyte]; -} - -// hlvoid is a void (used for functions that return nothing) - -table hlvoid { -} - -// This represents a parameter value in a function call - -union ParameterValue { - hlint, - hluint, - hllong, - hlulong, - hlfloat, - hldouble, - hlstring, - hlbool, - hlvecbytes, -} - -// This represents a parameter type in a function definition - -enum ParameterType : ubyte { - hlint, - hluint, - hllong, - hlulong, - hlfloat, - hldouble, - hlstring, - hlbool, - hlvecbytes, -} - -enum ReturnType : ubyte { - hlint, - hluint, - hllong, - hlulong, - hlfloat, - hldouble, - hlstring, - hlbool, - hlvoid, - hlsizeprefixedbuffer, -} - -union ReturnValue { - hlint, - hluint, - hllong, - hlulong, - hlfloat, - hldouble, - hlstring, - hlbool, - hlvoid, - hlsizeprefixedbuffer, -} diff --git a/src/schema/guest_error.fbs b/src/schema/guest_error.fbs deleted file mode 100644 index 14dfa85e4..000000000 --- a/src/schema/guest_error.fbs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Hyperlight.Generated; - -enum ErrorCode: ulong { - NoError = 0, // The function call was successful - UnsupportedParameterType = 2, // The type of the parameter is not supported by the Guest. - GuestFunctionNameNotProvided = 3, // The Guest function name was not provided by the host. - GuestFunctionNotFound = 4, // The function does not exist in the Guest. - GuestFunctionIncorrecNoOfParameters = 5, // Incorrect number of parameters for the guest function. - GispatchFunctionPointerNotSet = 6, // Host Call Dispatch Function Pointer is not present. - OutbError = 7, // Error in OutB Function - UnknownError = 8, // The guest error is unknown. - StackOverflow = 9, // Guest stack allocations caused stack overflow - GsCheckFailed = 10, // __security_check_cookie failed - TooManyGuestFunctions = 11, // The guest tried to register too many guest functions - FailureInDlmalloc = 12, // this error is set when dlmalloc calls ABORT (e.g. function defined in ABORT (dlmalloc_abort() calls setError with this errorcode) - MallocFailed = 13, // this error is set when malloc returns 0 bytes. - GuestFunctionParameterTypeMismatch = 14, // The function call parameter type was not the expected type. - GuestError = 15, // An error occurred in the guest Guest implementation should use this along with a message when calling setError. - ArrayLengthParamIsMissing = 16, // Expected a int parameter to follow a byte array - HostError = 17 // Guest called Host Function, which errored. -} - -table GuestError { - code: ErrorCode; - message: string; -} - -root_type GuestError; \ No newline at end of file diff --git a/src/schema/guest_log_data.fbs b/src/schema/guest_log_data.fbs deleted file mode 100644 index d9f64c60a..000000000 --- a/src/schema/guest_log_data.fbs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Hyperlight.Generated; - -enum LogLevel: uint8 { - Trace = 0, - Debug = 1, - Information = 2, - Warning = 3, - Error = 4, - Critical = 5, - None = 6, -} - -table GuestLogData { - message: string; - source: string; - level: LogLevel; - caller: string; - source_file: string; - line: uint32; -} - -root_type GuestLogData; diff --git a/src/schema/guest_trace_data.fbs b/src/schema/guest_trace_data.fbs deleted file mode 100644 index ebecc8f05..000000000 --- a/src/schema/guest_trace_data.fbs +++ /dev/null @@ -1,51 +0,0 @@ -namespace Hyperlight.Generated; - -table KeyValue { - key: string (required); - value: string (required); -} - -table OpenSpanType { - id: ulong; - parent: ulong = null; - name: string (required); - target: string (required); - tsc: ulong; - fields: [KeyValue]; -} - -table CloseSpanType { - id: ulong; - tsc: ulong; -} - -table LogEventType { - parent_id: ulong; - name: string (required); - tsc: ulong; - fields: [KeyValue]; -} - -table EditSpanType { - id: ulong; - fields: [KeyValue]; -} - -table GuestStartType { - tsc: ulong; -} - -// Result-like union -union GuestEventType { - OpenSpan:OpenSpanType, - CloseSpan:CloseSpanType, - LogEvent:LogEventType, - EditSpan:EditSpanType, - GuestStart:GuestStartType, -} - -table GuestEventEnvelopeType { - event: GuestEventType; -} - -root_type GuestEventEnvelopeType; diff --git a/src/schema/host_function_definition.fbs b/src/schema/host_function_definition.fbs deleted file mode 100644 index 2367007b7..000000000 --- a/src/schema/host_function_definition.fbs +++ /dev/null @@ -1,11 +0,0 @@ -include "function_types.fbs"; - -namespace Hyperlight.Generated; - -table HostFunctionDefinition { - function_name:string(required, key); - parameters:[ParameterType]; - return_type:ReturnType; -} - -root_type HostFunctionDefinition; \ No newline at end of file diff --git a/src/schema/host_function_details.fbs b/src/schema/host_function_details.fbs deleted file mode 100644 index 5ebd68576..000000000 --- a/src/schema/host_function_details.fbs +++ /dev/null @@ -1,9 +0,0 @@ -include "host_function_definition.fbs"; - -namespace Hyperlight.Generated; - -table HostFunctionDetails { - functions:[HostFunctionDefinition]; -} - -root_type HostFunctionDetails; \ No newline at end of file From 787d53719eb71da417730d5d221f89c949e8f930 Mon Sep 17 00:00:00 2001 From: Jorge Prendes Date: Thu, 8 Jan 2026 12:40:28 +0000 Subject: [PATCH 4/5] Use new API in host and guest Signed-off-by: Jorge Prendes --- .../src/guest_handle/host_comm.rs | 26 +++++++++++-------- src/hyperlight_guest/src/guest_handle/io.rs | 5 ++-- .../src/guest_function/call.rs | 7 +++-- src/hyperlight_guest_capi/src/error.rs | 7 +++-- src/hyperlight_host/benches/benchmarks.rs | 14 +++++----- src/hyperlight_host/src/mem/mgr.rs | 15 ++++++----- src/hyperlight_host/src/mem/shared_mem.rs | 10 ++++--- src/hyperlight_host/src/sandbox/host_funcs.rs | 3 ++- .../src/sandbox/initialized_multi_use.rs | 9 +++---- src/hyperlight_host/src/sandbox/outb.rs | 7 ++--- 10 files changed, 57 insertions(+), 46 deletions(-) diff --git a/src/hyperlight_guest/src/guest_handle/host_comm.rs b/src/hyperlight_guest/src/guest_handle/host_comm.rs index 37c5979d9..f1d21eea6 100644 --- a/src/hyperlight_guest/src/guest_handle/host_comm.rs +++ b/src/hyperlight_guest/src/guest_handle/host_comm.rs @@ -19,7 +19,6 @@ use alloc::string::ToString; use alloc::vec::Vec; use core::slice::from_raw_parts; -use flatbuffers::FlatBufferBuilder; use hyperlight_common::flatbuffer_wrappers::function_call::{FunctionCall, FunctionCallType}; use hyperlight_common::flatbuffer_wrappers::function_types::{ FunctionCallResult, ParameterValue, ReturnType, ReturnValue, @@ -28,7 +27,9 @@ use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode; use hyperlight_common::flatbuffer_wrappers::guest_log_data::GuestLogData; use hyperlight_common::flatbuffer_wrappers::guest_log_level::LogLevel; use hyperlight_common::flatbuffer_wrappers::host_function_details::HostFunctionDetails; -use hyperlight_common::flatbuffer_wrappers::util::estimate_flatbuffer_capacity; +use hyperlight_common::flatbuffer_wrappers::util::{ + decode, encode, encode_extend, estimate_flatbuffer_capacity, +}; use hyperlight_common::outb::OutBAction; use tracing::instrument; @@ -124,10 +125,15 @@ impl GuestHandle { return_type, ); - let mut builder = FlatBufferBuilder::with_capacity(estimated_capacity); - - let host_function_call_buffer = host_function_call.encode(&mut builder); - self.push_shared_output_data(host_function_call_buffer)?; + let host_function_call_buffer = Vec::with_capacity(estimated_capacity); + let host_function_call_buffer = + encode_extend(&host_function_call, host_function_call_buffer).map_err(|e| { + HyperlightGuestError::new( + ErrorCode::GuestError, + format!("Error serializing host function call to flatbuffer: {}", e), + ) + })?; + self.push_shared_output_data(&host_function_call_buffer)?; unsafe { out32(OutBAction::CallFunction as u16, 0); @@ -163,8 +169,7 @@ impl GuestHandle { let host_function_details_slice: &[u8] = unsafe { from_raw_parts(host_function_details_buffer, host_function_details_size) }; - host_function_details_slice - .try_into() + decode(host_function_details_slice) .expect("Failed to convert buffer to HostFunctionDetails") } @@ -189,9 +194,8 @@ impl GuestHandle { line, ); - let bytes: Vec = guest_log_data - .try_into() - .expect("Failed to convert GuestLogData to bytes"); + let bytes: Vec = + encode(&guest_log_data).expect("Failed to convert GuestLogData to bytes"); self.push_shared_output_data(&bytes) .expect("Unable to push log data to shared output data"); diff --git a/src/hyperlight_guest/src/guest_handle/io.rs b/src/hyperlight_guest/src/guest_handle/io.rs index 4c7f1b819..572551d16 100644 --- a/src/hyperlight_guest/src/guest_handle/io.rs +++ b/src/hyperlight_guest/src/guest_handle/io.rs @@ -20,6 +20,7 @@ use core::any::type_name; use core::slice::from_raw_parts_mut; use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode; +use hyperlight_common::flatbuffer_wrappers::util::{Deserialize, decode}; use tracing::{Span, instrument}; use super::handle::GuestHandle; @@ -30,7 +31,7 @@ impl GuestHandle { #[instrument(skip_all, parent = Span::current(), level= "Trace")] pub fn try_pop_shared_input_data_into(&self) -> Result where - T: for<'a> TryFrom<&'a [u8]>, + T: for<'a> Deserialize<'a>, { let peb_ptr = self.peb().unwrap(); let input_stack_size = unsafe { (*peb_ptr).input_stack.size as usize }; @@ -69,7 +70,7 @@ impl GuestHandle { let buffer = &idb[last_element_offset_rel as usize..]; // convert the buffer to T - let type_t = match T::try_from(buffer) { + let type_t = match decode::(buffer) { Ok(t) => Ok(t), Err(_e) => { return Err(HyperlightGuestError::new( diff --git a/src/hyperlight_guest_bin/src/guest_function/call.rs b/src/hyperlight_guest_bin/src/guest_function/call.rs index c460b06c6..8777abeea 100644 --- a/src/hyperlight_guest_bin/src/guest_function/call.rs +++ b/src/hyperlight_guest_bin/src/guest_function/call.rs @@ -17,10 +17,10 @@ limitations under the License. use alloc::format; use alloc::vec::Vec; -use flatbuffers::FlatBufferBuilder; use hyperlight_common::flatbuffer_wrappers::function_call::{FunctionCall, FunctionCallType}; use hyperlight_common::flatbuffer_wrappers::function_types::{FunctionCallResult, ParameterType}; use hyperlight_common::flatbuffer_wrappers::guest_error::{ErrorCode, GuestError}; +use hyperlight_common::flatbuffer_wrappers::util::encode; use hyperlight_guest::error::{HyperlightGuestError, Result}; use hyperlight_guest::exit::halt; use tracing::{Span, instrument}; @@ -107,10 +107,9 @@ fn internal_dispatch_function() { Err(err) => { let guest_error = Err(GuestError::new(err.kind, err.message)); let fcr = FunctionCallResult::new(guest_error); - let mut builder = FlatBufferBuilder::new(); - let data = fcr.encode(&mut builder); + let data = encode(&fcr).unwrap(); handle - .push_shared_output_data(data) + .push_shared_output_data(&data) .expect("Failed to serialize function call result"); } } diff --git a/src/hyperlight_guest_capi/src/error.rs b/src/hyperlight_guest_capi/src/error.rs index 03217600e..3e1e4931c 100644 --- a/src/hyperlight_guest_capi/src/error.rs +++ b/src/hyperlight_guest_capi/src/error.rs @@ -16,9 +16,9 @@ limitations under the License. use core::ffi::{CStr, c_char}; -use flatbuffers::FlatBufferBuilder; use hyperlight_common::flatbuffer_wrappers::function_types::FunctionCallResult; use hyperlight_common::flatbuffer_wrappers::guest_error::{ErrorCode, GuestError}; +use hyperlight_common::flatbuffer_wrappers::util::encode; use hyperlight_guest_bin::GUEST_HANDLE; use crate::alloc::borrow::ToOwned; @@ -33,12 +33,11 @@ pub extern "C" fn hl_set_error(err: ErrorCode, message: *const c_char) { .to_owned(), )); let fcr = FunctionCallResult::new(guest_error); - let mut builder = FlatBufferBuilder::new(); - let data = fcr.encode(&mut builder); + let data = encode(&fcr).unwrap(); unsafe { #[allow(static_mut_refs)] // we are single threaded GUEST_HANDLE - .push_shared_output_data(data) + .push_shared_output_data(&data) .expect("Failed to set error") } } diff --git a/src/hyperlight_host/benches/benchmarks.rs b/src/hyperlight_host/benches/benchmarks.rs index 70b0a0416..210f48107 100644 --- a/src/hyperlight_host/benches/benchmarks.rs +++ b/src/hyperlight_host/benches/benchmarks.rs @@ -24,10 +24,11 @@ use std::thread; use std::time::{Duration, Instant}; use criterion::{Criterion, criterion_group, criterion_main}; -use flatbuffers::FlatBufferBuilder; use hyperlight_common::flatbuffer_wrappers::function_call::{FunctionCall, FunctionCallType}; use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType}; -use hyperlight_common::flatbuffer_wrappers::util::estimate_flatbuffer_capacity; +use hyperlight_common::flatbuffer_wrappers::util::{ + decode, encode, encode_extend, estimate_flatbuffer_capacity, +}; use hyperlight_host::GuestBinary; use hyperlight_host::sandbox::{MultiUseSandbox, SandboxConfiguration, UninitializedSandbox}; use hyperlight_testing::sandbox_sizes::{LARGE_HEAP_SIZE, MEDIUM_HEAP_SIZE, SMALL_HEAP_SIZE}; @@ -436,18 +437,17 @@ fn function_call_serialization_benchmark(c: &mut Criterion) { function_call.function_name.as_str(), function_call.parameters.as_deref().unwrap_or(&[]), ); - let mut builder = FlatBufferBuilder::with_capacity(estimated_capacity); - let serialized: &[u8] = function_call.encode(&mut builder); + let serialized = Vec::with_capacity(estimated_capacity); + let serialized = encode_extend(&function_call, serialized).unwrap(); std::hint::black_box(serialized); }); }); group.bench_function("deserialize_function_call", |b| { - let mut builder = FlatBufferBuilder::new(); - let bytes = function_call.clone().encode(&mut builder); + let bytes = encode(&function_call).unwrap(); b.iter(|| { - let deserialized: FunctionCall = bytes.try_into().unwrap(); + let deserialized: FunctionCall = decode(&bytes).unwrap(); std::hint::black_box(deserialized); }); }); diff --git a/src/hyperlight_host/src/mem/mgr.rs b/src/hyperlight_host/src/mem/mgr.rs index 6d1cea0f5..fb2d0142a 100644 --- a/src/hyperlight_host/src/mem/mgr.rs +++ b/src/hyperlight_host/src/mem/mgr.rs @@ -16,13 +16,13 @@ limitations under the License. #[cfg(feature = "init-paging")] use std::cmp::Ordering; -use flatbuffers::FlatBufferBuilder; use hyperlight_common::flatbuffer_wrappers::function_call::{ FunctionCall, validate_guest_function_call_buffer, }; use hyperlight_common::flatbuffer_wrappers::function_types::FunctionCallResult; use hyperlight_common::flatbuffer_wrappers::guest_log_data::GuestLogData; use hyperlight_common::flatbuffer_wrappers::host_function_details::HostFunctionDetails; +use hyperlight_common::flatbuffer_wrappers::util::{decode, encode}; #[cfg(feature = "init-paging")] use hyperlight_common::vmem; #[cfg(feature = "init-paging")] @@ -221,14 +221,14 @@ impl SandboxMemoryManager { /// Writes host function details to memory #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] pub(crate) fn write_buffer_host_function_details(&mut self, buffer: &[u8]) -> Result<()> { - let host_function_details = HostFunctionDetails::try_from(buffer).map_err(|e| { + let host_function_details: HostFunctionDetails = decode(buffer).map_err(|e| { new_error!( "write_buffer_host_function_details: failed to convert buffer to HostFunctionDetails: {}", e ) })?; - let host_function_call_buffer: Vec = (&host_function_details).try_into().map_err(|_| { + let host_function_call_buffer: Vec = encode(&host_function_details).map_err(|_| { new_error!( "write_buffer_host_function_details: failed to convert HostFunctionDetails to Vec" ) @@ -353,13 +353,16 @@ impl SandboxMemoryManager { &mut self, res: &FunctionCallResult, ) -> Result<()> { - let mut builder = FlatBufferBuilder::new(); - let data = res.encode(&mut builder); + let data = encode(res).map_err(|_| { + new_error!( + "write_response_from_host_function_call: failed to convert FunctionCallResult to Vec" + ) + })?; self.shared_mem.push_buffer( self.layout.input_data_buffer_offset, self.layout.sandbox_memory_config.get_input_data_size(), - data, + &data, ) } diff --git a/src/hyperlight_host/src/mem/shared_mem.rs b/src/hyperlight_host/src/mem/shared_mem.rs index 824cfde04..6d8abf1fe 100644 --- a/src/hyperlight_host/src/mem/shared_mem.rs +++ b/src/hyperlight_host/src/mem/shared_mem.rs @@ -21,6 +21,7 @@ use std::io::Error; use std::ptr::null_mut; use std::sync::{Arc, RwLock}; +use hyperlight_common::flatbuffer_wrappers::util::{Deserialize, decode}; use hyperlight_common::mem::PAGE_SIZE_USIZE; use tracing::{Span, instrument}; #[cfg(target_os = "windows")] @@ -887,7 +888,7 @@ impl HostSharedMemory { buffer_size: usize, ) -> Result where - T: for<'b> TryFrom<&'b [u8]>, + T: for<'b> Deserialize<'b>, { // get the stackpointer let stack_pointer_rel = self.read::(buffer_start_offset)? as usize; @@ -912,17 +913,20 @@ impl HostSharedMemory { // Get the size of the flatbuffer buffer from memory let fb_buffer_size = { + stack_pointer_rel - last_element_offset_rel - 8 + /* let size_i32 = self.read::(last_element_offset_abs)? + 4; // ^^^ flatbuffer byte arrays are prefixed by 4 bytes // indicating its size, so, to get the actual size, we need // to add 4. usize::try_from(size_i32) - }?; + */ + }; let mut result_buffer = vec![0; fb_buffer_size]; self.copy_to_slice(&mut result_buffer, last_element_offset_abs)?; - let to_return = T::try_from(result_buffer.as_slice()).map_err(|_e| { + let to_return: T = decode(result_buffer.as_slice()).map_err(|_e| { new_error!( "pop_buffer_into: failed to convert buffer to {}", type_name::() diff --git a/src/hyperlight_host/src/sandbox/host_funcs.rs b/src/hyperlight_host/src/sandbox/host_funcs.rs index 52160539a..b3d7b32ee 100644 --- a/src/hyperlight_host/src/sandbox/host_funcs.rs +++ b/src/hyperlight_host/src/sandbox/host_funcs.rs @@ -22,6 +22,7 @@ use hyperlight_common::flatbuffer_wrappers::function_types::{ }; use hyperlight_common::flatbuffer_wrappers::host_function_definition::HostFunctionDefinition; use hyperlight_common::flatbuffer_wrappers::host_function_details::HostFunctionDetails; +use hyperlight_common::flatbuffer_wrappers::util::encode; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; use tracing::{Span, instrument}; @@ -74,7 +75,7 @@ impl FunctionRegistry { let hfd = HostFunctionDetails::from(self); - let buffer: Vec = (&hfd).try_into().map_err(|e| { + let buffer: Vec = encode(&hfd).map_err(|e| { new_error!( "Error serializing host function details to flatbuffer: {}", e diff --git a/src/hyperlight_host/src/sandbox/initialized_multi_use.rs b/src/hyperlight_host/src/sandbox/initialized_multi_use.rs index 349536cfc..019e9c48c 100644 --- a/src/hyperlight_host/src/sandbox/initialized_multi_use.rs +++ b/src/hyperlight_host/src/sandbox/initialized_multi_use.rs @@ -23,13 +23,12 @@ use std::path::Path; use std::sync::atomic::Ordering; use std::sync::{Arc, Mutex}; -use flatbuffers::FlatBufferBuilder; use hyperlight_common::flatbuffer_wrappers::function_call::{FunctionCall, FunctionCallType}; use hyperlight_common::flatbuffer_wrappers::function_types::{ ParameterValue, ReturnType, ReturnValue, }; use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode; -use hyperlight_common::flatbuffer_wrappers::util::estimate_flatbuffer_capacity; +use hyperlight_common::flatbuffer_wrappers::util::{encode_extend, estimate_flatbuffer_capacity}; use tracing::{Span, instrument}; use super::Callable; @@ -592,10 +591,10 @@ impl MultiUseSandbox { return_type, ); - let mut builder = FlatBufferBuilder::with_capacity(estimated_capacity); - let buffer = fc.encode(&mut builder); + let buffer = Vec::with_capacity(estimated_capacity); + let buffer = encode_extend(&fc, buffer).unwrap(); - self.mem_mgr.write_guest_function_call(buffer)?; + self.mem_mgr.write_guest_function_call(&buffer)?; self.vm.dispatch_call_from_host( self.dispatch_ptr.clone(), diff --git a/src/hyperlight_host/src/sandbox/outb.rs b/src/hyperlight_host/src/sandbox/outb.rs index 62d8d4c17..c40034dbf 100644 --- a/src/hyperlight_host/src/sandbox/outb.rs +++ b/src/hyperlight_host/src/sandbox/outb.rs @@ -196,6 +196,7 @@ pub(crate) fn handle_outb( #[cfg(test)] mod tests { use hyperlight_common::flatbuffer_wrappers::guest_log_level::LogLevel; + use hyperlight_common::flatbuffer_wrappers::util::encode; use hyperlight_testing::logger::{LOGGER, Logger}; use hyperlight_testing::simple_guest_as_string; use log::Level; @@ -254,7 +255,7 @@ mod tests { let mut mgr = new_mgr(); let log_msg = new_guest_log_data(LogLevel::Information); - let guest_log_data_buffer: Vec = log_msg.try_into().unwrap(); + let guest_log_data_buffer: Vec = encode(&log_msg).unwrap(); let offset = mgr.layout.get_output_data_offset(); mgr.get_shared_mem_mut() .push_buffer( @@ -292,7 +293,7 @@ mod tests { let layout = mgr.layout; let log_data = new_guest_log_data(level); - let guest_log_data_buffer: Vec = log_data.clone().try_into().unwrap(); + let guest_log_data_buffer: Vec = encode(&log_data).unwrap(); mgr.get_shared_mem_mut() .push_buffer( layout.get_output_data_offset(), @@ -374,7 +375,7 @@ mod tests { let log_data: GuestLogData = new_guest_log_data(level); subscriber.clear(); - let guest_log_data_buffer: Vec = log_data.try_into().unwrap(); + let guest_log_data_buffer: Vec = encode(&log_data).unwrap(); mgr.get_shared_mem_mut() .push_buffer( layout.get_output_data_offset(), From 63bf49a6791a4a0b8ed3c550a82da75926ea2922 Mon Sep 17 00:00:00 2001 From: Jorge Prendes Date: Thu, 8 Jan 2026 15:11:48 +0000 Subject: [PATCH 5/5] make clippy happy Signed-off-by: Jorge Prendes --- .../src/flatbuffer_wrappers/guest_trace_data.rs | 2 ++ src/hyperlight_common/src/flatbuffer_wrappers/util.rs | 2 ++ src/hyperlight_host/src/sandbox/initialized_multi_use.rs | 1 + 3 files changed, 5 insertions(+) diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/guest_trace_data.rs b/src/hyperlight_common/src/flatbuffer_wrappers/guest_trace_data.rs index 4ff26d119..4345ba3b8 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/guest_trace_data.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/guest_trace_data.rs @@ -177,6 +177,7 @@ impl EventsEncoder for EventsBatchEncoderGeneric { // - If the estimate is too low, the FlatBuffer builder reallocates as needed. let estimated_size = estimate_event(event); let serialized = Vec::with_capacity(estimated_size); + #[allow(clippy::unwrap_used)] let serialized = encode_extend(event, serialized).unwrap(); // Check if adding this event would exceed capacity @@ -213,6 +214,7 @@ impl EventsEncoder for EventsBatchEncoderGeneric { } pub fn estimate_event(event: &GuestEvent) -> usize { + #[allow(clippy::unwrap_used)] encoded_size(event).unwrap() } diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/util.rs b/src/hyperlight_common/src/flatbuffer_wrappers/util.rs index 3b3b186d4..5073d0f58 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/util.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/util.rs @@ -24,6 +24,7 @@ use crate::func::ReturnValue; /// Flatbuffer-encodes the given value pub fn get_flatbuffer_result>(val: T) -> Vec { let result = FunctionCallResult::new(Ok(val.into())); + #[allow(clippy::unwrap_used)] encode(&result).unwrap() } @@ -79,6 +80,7 @@ pub fn estimate_flatbuffer_capacity(function_name: &str, args: &[ParameterValue] crate::flatbuffer_wrappers::function_types::ReturnType::Void, ); + #[allow(clippy::unwrap_used)] let estimated_capacity = encoded_size(&dummy).unwrap(); /* diff --git a/src/hyperlight_host/src/sandbox/initialized_multi_use.rs b/src/hyperlight_host/src/sandbox/initialized_multi_use.rs index 019e9c48c..9a299eb6f 100644 --- a/src/hyperlight_host/src/sandbox/initialized_multi_use.rs +++ b/src/hyperlight_host/src/sandbox/initialized_multi_use.rs @@ -592,6 +592,7 @@ impl MultiUseSandbox { ); let buffer = Vec::with_capacity(estimated_capacity); + #[allow(clippy::unwrap_used)] let buffer = encode_extend(&fc, buffer).unwrap(); self.mem_mgr.write_guest_function_call(&buffer)?;