pub trait PhoneXmlDocument:
Sealed
+ Sized
+ Serialize
+ DeserializeOwned {
const ROOT: &'static [u8];
const MAXIMUM_BYTES: usize;
// Required method
fn validate_document(&self) -> Result<(), PhoneXmlError>;
// Provided methods
fn parse_xml(document: &[u8]) -> Result<Self, PhoneXmlError> { ... }
fn parse_xml_with_limit(
document: &[u8],
maximum_bytes: usize,
) -> Result<Self, PhoneXmlError> { ... }
fn serialize_xml(&self) -> Result<String, PhoneXmlError> { ... }
fn serialize_xml_with_limit(
&self,
maximum_bytes: usize,
) -> Result<String, PhoneXmlError> { ... }
}Expand description
Common bounded parsing and serialization contract for a complete phone XML document.
The trait is sealed because every supported root has its own schema and validation policy. It centralizes the security boundary without allowing a downstream type to opt into parsing with a guessed root or size limit.
Required Associated Constants§
Sourceconst MAXIMUM_BYTES: usize
const MAXIMUM_BYTES: usize
Default maximum encoded document size, in bytes.
Required Methods§
Sourcefn validate_document(&self) -> Result<(), PhoneXmlError>
fn validate_document(&self) -> Result<(), PhoneXmlError>
Checks schema invariants that cannot be expressed by Serde types alone.
Provided Methods§
Sourcefn parse_xml(document: &[u8]) -> Result<Self, PhoneXmlError>
fn parse_xml(document: &[u8]) -> Result<Self, PhoneXmlError>
Parses the exact schema root within Self::MAXIMUM_BYTES.
Sourcefn parse_xml_with_limit(
document: &[u8],
maximum_bytes: usize,
) -> Result<Self, PhoneXmlError>
fn parse_xml_with_limit( document: &[u8], maximum_bytes: usize, ) -> Result<Self, PhoneXmlError>
Parses the exact schema root within a caller-selected byte limit.
This is useful when a transport or device profile imposes a bound
smaller than Self::MAXIMUM_BYTES.
Sourcefn serialize_xml(&self) -> Result<String, PhoneXmlError>
fn serialize_xml(&self) -> Result<String, PhoneXmlError>
Validates and serializes the document within Self::MAXIMUM_BYTES.
Sourcefn serialize_xml_with_limit(
&self,
maximum_bytes: usize,
) -> Result<String, PhoneXmlError>
fn serialize_xml_with_limit( &self, maximum_bytes: usize, ) -> Result<String, PhoneXmlError>
Validates and serializes the document within a caller-selected byte limit.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".