#[repr(transparent)]pub struct GrpcSlice(_);
Expand description
A convenient rust wrapper for the type grpc_slice
.
It’s expected that the slice should be initialized.
Implementations
sourceimpl GrpcSlice
impl GrpcSlice
sourcepub fn as_slice(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn as_slice(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns a slice of inner buffer.
pub fn is_empty(&self) -> bool
sourcepub fn from_static_slice(s: &'static [u8]) -> GrpcSlice
pub fn from_static_slice(s: &'static [u8]) -> GrpcSlice
Creates a slice from static rust slice.
Same as From<&[u8]>
but without copying the buffer.
sourcepub fn from_static_str(s: &'static str) -> GrpcSlice
pub fn from_static_str(s: &'static str) -> GrpcSlice
Creates a GrpcSlice
from static rust str.
Same as from_str
but without allocation.
sourcepub unsafe fn realloc(&mut self, cap: usize) -> &mut [MaybeUninit<u8>]
pub unsafe fn realloc(&mut self, cap: usize) -> &mut [MaybeUninit<u8>]
Reallocates current slice with given capacity.
The length of returned slice is the exact same as given cap.
Safety
Caller is expected to initialize all available bytes to guarantee safety of this slice.
pub fn as_mut_ptr(&mut self) -> *mut grpc_slice
Trait Implementations
sourceimpl From<&'_ [u8]> for GrpcSlice
impl From<&'_ [u8]> for GrpcSlice
Creates a GrpcSlice
from rust slice.
The data inside slice will be cloned. If the data can’t fit inline, necessary buffer will be allocated.
sourceimpl From<&'_ CStr> for GrpcSlice
impl From<&'_ CStr> for GrpcSlice
Creates a GrpcSlice
from rust CStr
.
The data inside CStr
will be cloned. If the data can’t fit inline,
necessary buffer will be allocated.
sourceimpl From<&'_ str> for GrpcSlice
impl From<&'_ str> for GrpcSlice
Creates a GrpcSlice
from rust str.
The data inside str will be cloned. If the data can’t fit inline, necessary buffer will be allocated.
sourceimpl From<CString> for GrpcSlice
impl From<CString> for GrpcSlice
Creates a GrpcSlice
from rust cstring.
If the cstring can’t fit inline, there will be allocations.
sourceimpl From<String> for GrpcSlice
impl From<String> for GrpcSlice
Creates a GrpcSlice
from rust string.
If the string can’t fit inline, there will be allocations.
impl Send for GrpcSlice
impl Sync for GrpcSlice
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more