[−][src]Enum azure_functions::http::Body
Represents the body of a HTTP request or response.
Variants
Represents an empty body.
Represents a string body with a default content type of text/plain
.
Represents a JSON body with a default content type of application/json
.
Represents a body from a slice of bytes with a default content type of application/octet-stream
.
Methods
impl<'_> Body<'_>
[src]
pub fn default_content_type(&self) -> &str
[src]
Gets the default content type for a body.
Returns application/json
for Body::Json
.
Returns application/octet-stream
for Body::Bytes
.
Returns text/plain
for all other Body
values.
Examples
use azure_functions::http::Body; let body: Body = [1, 2, 3][..].into(); assert_eq!(body.default_content_type(), "application/octet-stream");
pub fn as_str(&self) -> Option<&str>
[src]
Gets the body as a string.
Returns None if there is no valid string representation of the message.
Examples
use azure_functions::http::Body; use std::borrow::Cow; let body = Body::String(Cow::Borrowed("test")); assert_eq!(body.as_str().unwrap(), "test");
pub fn as_bytes(&self) -> &[u8]
[src]
Gets the body as a slice of bytes.
Examples
use azure_functions::http::Body; use std::borrow::Cow; let body = Body::String(Cow::Borrowed("test")); assert_eq!(body.as_bytes(), "test".as_bytes());
pub fn as_json<'b, T>(&'b self) -> Result<T> where
T: Deserialize<'b>,
[src]
T: Deserialize<'b>,
Deserializes the body as JSON to the requested type.
Examples
use azure_functions::http::Body; use std::borrow::Cow; use serde::Deserialize; #[derive(Deserialize)] struct Data { message: String } let body = Body::String(Cow::Borrowed(r#"{ "message": "hello" }"#)); let data = body.as_json::<Data>().unwrap(); assert_eq!(data.message, "hello");
Trait Implementations
impl<'a> Into<Body<'a>> for Blob
[src]
impl<'a> Into<Body<'a>> for CosmosDbDocument
[src]
impl<'a> Into<Body<'a>> for Vec<CosmosDbDocument>
[src]
impl<'a> Into<Body<'a>> for OrchestrationData
[src]
impl<'a> Into<Body<'a>> for EventHubMessage
[src]
impl<'a> Into<Body<'a>> for GenericInput
[src]
impl<'a> Into<Body<'a>> for QueueMessage
[src]
impl<'a> Into<Body<'a>> for ServiceBusMessage
[src]
impl<'a> Into<Body<'a>> for SignalRConnectionInfo
[src]
impl<'a> Into<Body<'a>> for Table
[src]
impl<'a> Into<Body<'a>> for Value
[src]
impl<'a> From<&'a str> for Body<'a>
[src]
impl<'_> From<String> for Body<'_>
[src]
impl<'_, '_> From<&'_ Value> for Body<'_>
[src]
impl<'_> From<Value> for Body<'_>
[src]
impl<'a> From<&'a [u8]> for Body<'a>
[src]
impl<'_> From<Vec<u8>> for Body<'_>
[src]
impl<'a> Clone for Body<'a>
[src]
impl<'_> Display for Body<'_>
[src]
impl<'a> Debug for Body<'a>
[src]
Auto Trait Implementations
impl<'a> Send for Body<'a>
impl<'a> Sync for Body<'a>
impl<'a> Unpin for Body<'a>
impl<'a> UnwindSafe for Body<'a>
impl<'a> RefUnwindSafe for Body<'a>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> IntoRequest<T> for T
[src]
fn into_request(self) -> Request<T>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,