mirror of https://github.com/fafhrd91/actix-web
impl `From` for `Cow<'static, [u8]>` for `Binary`
This commit is contained in:
parent
c386353337
commit
f87ffa6016
10
src/body.rs
10
src/body.rs
|
@ -1,5 +1,6 @@
|
|||
use bytes::{Bytes, BytesMut};
|
||||
use futures::Stream;
|
||||
use std::borrow::Cow;
|
||||
use std::sync::Arc;
|
||||
use std::{fmt, mem};
|
||||
|
||||
|
@ -194,6 +195,15 @@ impl From<Vec<u8>> for Binary {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Cow<'static, [u8]>> for Binary {
|
||||
fn from(b: Cow<'static, [u8]>) -> Binary {
|
||||
match b {
|
||||
Cow::Borrowed(s) => Binary::Slice(s),
|
||||
Cow::Owned(vec) => Binary::Bytes(Bytes::from(vec)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for Binary {
|
||||
fn from(s: String) -> Binary {
|
||||
Binary::Bytes(Bytes::from(s))
|
||||
|
|
Loading…
Reference in New Issue