#![forbid(unsafe_code)]
#![warn(rust_2024_compatibility)]
#![allow(missing_docs, missing_debug_implementations)]
#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used))]
#[allow(
clippy::all,
clippy::pedantic,
clippy::restriction,
clippy::indexing_slicing,
clippy::expect_used,
clippy::unwrap_used,
clippy::panic,
missing_docs
)]
mod pb {
include!(concat!(env!("OUT_DIR"), "/mod.rs"));
}
pub use pb::*;
mod ext;
pub use ext::UnknownVariant;
pub static BUILTIN_FDS: &[u8] = include_bytes!(env!("OBS_PROTO_FDS"));
pub const ENVELOPE_FORMAT_VER: u32 = 3;
pub mod __private {
pub use buffa::{EnumValue, Enumeration, Message, MessageField, UnknownFields};
}
#[cfg(test)]
mod tests {
use buffa::Message as _;
use buffa_descriptor::generated::descriptor::FileDescriptorSet;
use super::*;
#[test]
fn test_should_decode_builtin_fds() {
let fds = FileDescriptorSet::decode_from_slice(BUILTIN_FDS).unwrap();
let names: Vec<_> = fds.file.iter().filter_map(|f| f.name.as_deref()).collect();
assert!(names.iter().any(|n| n.ends_with("envelope.proto")));
assert!(names.iter().any(|n| n.ends_with("builtin.proto")));
assert!(names.iter().any(|n| n.ends_with("self_events.proto")));
}
#[test]
fn test_envelope_format_ver_locked_at_three() {
assert_eq!(ENVELOPE_FORMAT_VER, 3);
}
#[test]
fn test_should_round_trip_envelope() {
let env = obs::v1::ObsEnvelope {
full_name: "obs.v1.ObsHelloEmitted".to_string(),
schema_hash: 0x1234_5678_9ABC_DEF0,
ts_ns: 1_700_000_000_000_000_000,
service: "test".to_string(),
..Default::default()
};
let mut buf = Vec::new();
env.encode(&mut buf);
let decoded = obs::v1::ObsEnvelope::decode_from_slice(&buf).unwrap();
assert_eq!(decoded.full_name, env.full_name);
assert_eq!(decoded.schema_hash, env.schema_hash);
assert_eq!(decoded.service, env.service);
}
}