pub enum ContentType {
ApplicationJson,
ApplicationXml,
TextPlain,
TextHtml,
FormUrlEncoded,
Unknown,
}Expand description
Represents different types of HTTP content types, such as JSON, XML, plain text, HTML, form URL encoded, and an unknown type.
Variants§
ApplicationJson
Represents the application/json content type.
ApplicationXml
Represents the application/xml content type.
TextPlain
Represents the text/plain content type.
TextHtml
Represents the text/html content type.
FormUrlEncoded
Represents the application/x-www-form-urlencoded content type.
Unknown
Represents an unknown or unrecognized content type.
Implementations§
Source§impl ContentType
impl ContentType
Sourcepub fn get_body_string<T>(&self, data: &T) -> String
pub fn get_body_string<T>(&self, data: &T) -> String
Public interface for getting a formatted body string based on the ContentType.
This method routes the data to the appropriate handler method based on the
ContentType, formatting the body accordingly.
§Type Parameters
T: The type of the data to be formatted, which must implementSerialize,Debug,Clone, andDefault.
§Parameters
data: The data to be formatted into the body string.
§Returns
A string containing the formatted body based on the content type, such as JSON, XML, plain text, HTML, etc.
Trait Implementations§
Source§impl Clone for ContentType
impl Clone for ContentType
Source§fn clone(&self) -> ContentType
fn clone(&self) -> ContentType
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContentType
impl Debug for ContentType
Source§impl Default for ContentType
impl Default for ContentType
Source§fn default() -> ContentType
fn default() -> ContentType
Returns the “default value” for a type. Read more
Source§impl FromStr for ContentType
impl FromStr for ContentType
Source§impl PartialEq for ContentType
impl PartialEq for ContentType
impl Eq for ContentType
impl StructuralPartialEq for ContentType
Auto Trait Implementations§
impl Freeze for ContentType
impl RefUnwindSafe for ContentType
impl Send for ContentType
impl Sync for ContentType
impl Unpin for ContentType
impl UnwindSafe for ContentType
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.