When trying to serialize Serialize object using bson::to_vec it gets to update_element_type which returns an error if the top level object is not ElementType::EmbeddedDocument
if matches!(t, ElementType::EmbeddedDocument) {
Is there a reason for this limitation? I tested the code without this check and it works.