pub enum RawData {
String(String),
Bytes(Bytes),
ArcBytes(Arc<Vec<u8>>),
}Variants§
Implementations§
Source§impl RawData
impl RawData
pub fn from_string<T: Into<String>>(value: T) -> RawData
pub fn from_arc_bytes(data: Arc<Vec<u8>>) -> Self
Sourcepub fn from_arc_slice(data: Arc<[u8]>) -> Self
pub fn from_arc_slice(data: Arc<[u8]>) -> Self
辅助构造:从 Arc<[u8]> 构建。该接口用于兼容旧版(0.4.6 之前)ArcBytes 表示,
会额外复制一次数据,建议尽快迁移到 Arc<Vec<u8>>。
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn to_bytes(&self) -> Bytes
Sourcepub fn into_bytes(self) -> Bytes
pub fn into_bytes(self) -> Bytes
按需取得 Bytes,消耗自身以在 String/Bytes 分支复用缓冲区。
pub fn is_zero_copy(&self) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RawData
impl RefUnwindSafe for RawData
impl Send for RawData
impl Sync for RawData
impl Unpin for RawData
impl UnwindSafe for RawData
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