# actix_web::Binary - Rust
API documentation for the Rust `Binary` enum in crate `actix_web`.
Keywords: rust, rustlang, rust-lang, Binary

# [−] [src] Enum actix_web::Binary

    pub enum Binary {
        Bytes(Bytes),
        Slice(&'static [u8]),
        SharedVec(Arc<Vec<u8>>),
        // some variants omitted
    }

Represents various types of binary body. `Content-Length` header is set to length of the body.

## Variants

`Bytes(Bytes)`

Bytes body

`Slice(&'static [u8])`

Static slice

`SharedVec(Arc<Vec<u8>>)`

Shared vec body

## Methods

###

`impl Binary`

[src]

####

`pub fn is_empty(&self) -> bool`

[src]

Returns `true` if body is empty

####

`pub fn len(&self) -> usize`

[src]

Length of body in bytes

####

`pub fn from_slice(s: &[u8]) -> Binary`

[src]

Create binary body from slice

####

`pub fn take(&mut self) -> Bytes`

[src]

Convert Binary to a Bytes instance

## Trait Implementations

###

`impl Responder for Binary`

[src]

#### `type Item = HttpResponse`

The associated item which can be returned.

#### `type Error = Error`

The associated error which can be returned.

####

`fn respond_to<S>(self, req: &HttpRequest<S>) -> Result<HttpResponse, Error>`

[src]

Convert itself to `AsyncResult` or `Error`.

###

`impl AsRef<[u8]> for Binary`

[src]

####

`fn as_ref(&self) -> &[u8]`

[src]

Performs the conversion.

###

`impl PartialEq<Binary> for Binary`

[src]

####

`fn eq(&self, other: &Binary) -> bool`

[src]

This method tests for `self` and `other` values to be equal, and is used by `==`. Read more

####

`fn ne(&self, other: &Binary) -> bool`

[src]

This method tests for `!=`.

###

`impl From<&'static str> for Binary`

[src]

####

`fn from(s: &'static str) -> Binary`

[src]

Performs the conversion.

###

`impl From<&'static [u8]> for Binary`

[src]

####

`fn from(s: &'static [u8]) -> Binary`

[src]

Performs the conversion.

###

`impl From<Vec<u8>> for Binary`

[src]

####

`fn from(vec: Vec<u8>) -> Binary`

[src]

Performs the conversion.

###

`impl From<String> for Binary`

[src]

####

`fn from(s: String) -> Binary`

[src]

Performs the conversion.

###

`impl<'a> From<&'a String> for Binary`

[src]

####

`fn from(s: &'a String) -> Binary`

[src]

Performs the conversion.

###

`impl From<Bytes> for Binary`

[src]

####

`fn from(s: Bytes) -> Binary`

[src]

Performs the conversion.

###

`impl From<BytesMut> for Binary`

[src]

####

`fn from(s: BytesMut) -> Binary`

[src]

Performs the conversion.

###

`impl From<Arc<String>> for Binary`

[src]

####

`fn from(body: Arc<String>) -> Binary`

[src]

Performs the conversion.

###

`impl<'a> From<&'a Arc<String>> for Binary`

[src]

####

`fn from(body: &'a Arc<String>) -> Binary`

[src]

Performs the conversion.

###

`impl From<Arc<Vec<u8>>> for Binary`

[src]

####

`fn from(body: Arc<Vec<u8>>) -> Binary`

[src]

Performs the conversion.

###

`impl<'a> From<&'a Arc<Vec<u8>>> for Binary`

[src]

####

`fn from(body: &'a Arc<Vec<u8>>) -> Binary`

[src]

Performs the conversion.

###

`impl Clone for Binary`

[src]

####

`fn clone(&self) -> Binary`

[src]

Returns a copy of the value. Read more

####

`fn clone_from(&mut self, source: &Self)`

1.0.0
[src]

Performs copy-assignment from `source`. Read more

###

`impl Into<Bytes> for Binary`

[src]

####

`fn into(self) -> Bytes`

[src]

Performs the conversion.

###

`impl Debug for Binary`

[src]

####

`fn fmt(&self, f: &mut Formatter) -> Result`

[src]

Formats the value using the given formatter. Read more

## Auto Trait Implementations

###

`impl Send for Binary`

###

`impl Sync for Binary`

## Blanket Implementations

###

`impl<T> ToOwned for T where T: Clone,`

[src]

#### `type Owned = T`

####

`fn to_owned(&self) -> T`

[src]

Creates owned data from borrowed data, usually by cloning. Read more

####

`fn clone_into(&self, target: &mut T)`

[src]

🔬 This is a nightly-only experimental API. (`toowned_clone_into`)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

###

`impl<T> From for T`

[src]

####

`fn from(t: T) -> T`

[src]

Performs the conversion.

###

`impl<T, U> Into for T where U: From<T>,`

[src]

####

`fn into(self) -> U`

[src]

Performs the conversion.

###

`impl<T, U> TryFrom for T where T: From<U>,`

[src]

#### `type Error = !`

🔬 This is a nightly-only experimental API. (`try_from`)

The type returned in the event of a conversion error.

####

`fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`

[src]

🔬 This is a nightly-only experimental API. (`try_from`)

Performs the conversion.

###

`impl<T> Borrow for T where T: ?Sized,`

[src]

####

`fn borrow(&self) -> &T`

[src]

Immutably borrows from an owned value. Read more

###

`impl<T> BorrowMut for T where T: ?Sized,`

[src]

####

`fn borrow_mut(&mut self) -> &mut T`

[src]

Mutably borrows from an owned value. Read more

###

`impl<T, U> TryInto for T where U: TryFrom<T>,`

[src]

#### `type Error = <U as TryFrom<T>>::Error`

🔬 This is a nightly-only experimental API. (`try_from`)

The type returned in the event of a conversion error.

####

`fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`

[src]

🔬 This is a nightly-only experimental API. (`try_from`)

Performs the conversion.

###

`impl<T> Any for T where T: 'static + ?Sized,`

[src]

####

`fn get_type_id(&self) -> TypeId`

[src]

🔬 This is a nightly-only experimental API. (`get_type_id`)

this method will likely be replaced by an associated static

Gets the `TypeId` of `self`. Read more

###

`impl<T> Erased for T`

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)