#[non_exhaustive]pub enum BodyType {
Plain,
Markdown,
Rich,
Other(String),
}Expand description
MIME type for a message body (draft-atwood-jmap-chat-00 §Message).
The spec defines three well-known values. Other(String) preserves any
unrecognized MIME type for lossless round-trip.
Wire strings: "text/plain", "text/markdown", "application/jmap-chat-rich".
§Forging caveat
Other(String) is pub, so callers can construct
BodyType::Other("text/plain".into()). The custom serde impl emits the
wrapped string verbatim on serialize and normalises canonical wire strings
to their typed variant on deserialize. Consequences:
BodyType::Other("text/plain".into()) != BodyType::Plainon PartialEq, but both serialize to"text/plain".Other("text/plain")->"text/plain"->Plainis a lossy round-trip (the variant changes shape).
Reserve Other(s) for genuinely unrecognised MIME types. Comparing wire-
string equality across two values requires matching on as_str(), not on
PartialEq.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Plain
"text/plain" — unformatted UTF-8 text.
Markdown
"text/markdown" — CommonMark-formatted text.
Rich
"application/jmap-chat-rich" — structured rich text (spans array).
Other(String)
Any unrecognized MIME type string, preserved as-is. See the “Forging caveat” section in the enum-level rustdoc.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for BodyType
impl<'de> Deserialize<'de> for BodyType
Source§fn deserialize<D>(d: D) -> Result<BodyType, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<BodyType, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Serialize for BodyType
impl Serialize for BodyType
Source§fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for BodyType
Auto Trait Implementations§
impl Freeze for BodyType
impl RefUnwindSafe for BodyType
impl Send for BodyType
impl Sync for BodyType
impl Unpin for BodyType
impl UnsafeUnpin for BodyType
impl UnwindSafe for BodyType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.