bytesandbrains_core/proto/
mod.rs1pub mod onnx {
3 include!(concat!(env!("OUT_DIR"), "/onnx.rs"));
4}
5
6pub mod bb_core_proto {
8 include!(concat!(env!("OUT_DIR"), "/bb_core.rs"));
9}
10
11pub use bb_core_proto::*;
13pub use onnx::TensorProto;
14
15pub const DATA_TYPE_FLOAT: i32 = 1;
17
18pub const DATA_TYPE_UINT8: i32 = 2;
20
21
22#[derive(Debug, Clone)]
23pub enum ProtoConversionError {
24 ConversionFailed(String),
25 InvalidDataType { expected: i32, actual: i32 },
26 InvalidTensorShape { expected: Vec<i64>, actual: Vec<i64> },
27}
28
29impl std::fmt::Display for ProtoConversionError {
30 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31 match self {
32 ProtoConversionError::ConversionFailed(msg) => write!(f, "Proto conversion failed: {}", msg),
33 ProtoConversionError::InvalidDataType { expected, actual } => {
34 write!(f, "Invalid data type: expected {}, actual {}", expected, actual)
35 }
36 ProtoConversionError::InvalidTensorShape { expected, actual } => {
37 write!(f, "Invalid tensor shape: expected {:?}, actual {:?}", expected, actual)
38 }
39 }
40 }
41}
42
43impl std::error::Error for ProtoConversionError {}
44
45mod conversions;
46pub use conversions::{addresses_from_proto, addresses_to_proto};