use bson::{bson, Bson as Value}; use schema_analysis::InferredSchema; mod shared; use shared::FormatTests; struct Bson; test_format!(Bson); impl FormatTests for Bson { fn convert_to_inferred_schema(value: Value) -> InferredSchema { let bytes = bson::to_vec(&value).unwrap(); let processed_schema: InferredSchema = bson::from_slice(&bytes).unwrap(); processed_schema } // Bson doesn't allow top-level primitives fn null() -> Option { None } fn boolean() -> Option { None } fn integer() -> Option { None } fn float() -> Option { None } fn string() -> Option { None } // Bson doesn't allow top-level arrays fn empty_sequence() -> Option { None } fn string_sequence() -> Option { None } fn integer_sequence() -> Option { None } fn mixed_sequence() -> Option { None } fn optional_mixed_sequence() -> Option { None } fn empty_map_struct() -> Option { Some(bson!({})) } fn map_struct_single() -> Option { Some(bson!({ "hello": 1 })) } fn map_struct_double() -> Option { Some(bson!({ "hello": 1, "world": "!" })) } fn sequence_map_struct_mixed() -> Option { None // Bson doesn't allow top-level arrays } fn test_sequence_map_struct_mixed() {} fn sequence_map_struct_optional_or_missing() -> Option { None // Bson doesn't allow top-level arrays } fn test_sequence_map_struct_optional_or_missing() {} fn map_struct_mixed_sequence() -> Option { Some(bson!({ "hello": 1, "world": "!", "sequence": ["one", "two", "three"] })) } fn map_struct_mixed_sequence_optional() -> Option { Some(bson!({ "hello": 1, "world": "!", "optional": null, "sequence": ["one", "two", "three", null] })) } }