surrealdb_types/flatbuffers/
table.rs1use surrealdb_protocol::fb::v1 as proto_fb;
2
3use super::{FromFlatbuffers, ToFlatbuffers};
4use crate::Table;
5
6impl ToFlatbuffers for Table {
7 type Output<'bldr> = flatbuffers::WIPOffset<proto_fb::StringValue<'bldr>>;
8
9 #[inline]
10 fn to_fb<'bldr>(
11 &self,
12 builder: &mut flatbuffers::FlatBufferBuilder<'bldr>,
13 ) -> anyhow::Result<Self::Output<'bldr>> {
14 let table = builder.create_string(self);
15 Ok(proto_fb::StringValue::create(
16 builder,
17 &proto_fb::StringValueArgs {
18 value: Some(table),
19 },
20 ))
21 }
22}
23
24impl FromFlatbuffers for Table {
25 type Input<'a> = proto_fb::StringValue<'a>;
26
27 #[inline]
28 fn from_fb(input: Self::Input<'_>) -> anyhow::Result<Self> {
29 Ok(Table::new(
30 input.value().ok_or_else(|| anyhow::anyhow!("Missing table value"))?.to_string(),
31 ))
32 }
33}