pub struct OwnedFB<T> { /* private fields */ }Expand description
Stores the owned bytes of the flatbuffer type and can access the actual type.
Implementations§
Source§impl<T> OwnedFB<T>
impl<T> OwnedFB<T>
pub fn new<'a>(buf: &'a [u8]) -> Result<OwnedFB<T>, InvalidFlatbuffer>where
T: Verifiable + Follow<'a> + 'a,
Sourcepub unsafe fn new_from_vec_unchecked(buf: Vec<u8>, index: usize) -> OwnedFB<T>
pub unsafe fn new_from_vec_unchecked(buf: Vec<u8>, index: usize) -> OwnedFB<T>
§Safety
Caller is responsible for verifying the buffer and align the type T.
Sourcepub unsafe fn new_from_builder_collapse(pair: (Vec<u8>, usize)) -> OwnedFB<T>
pub unsafe fn new_from_builder_collapse(pair: (Vec<u8>, usize)) -> OwnedFB<T>
§Safety
Caller is responsible for verifying the buffer and align the type T.
pub fn new_from_vec(
buf: Vec<u8>,
index: usize,
) -> Result<OwnedFB<T>, InvalidFlatbuffer>where
T: Verifiable + Follow<'static> + 'static,
Sourcepub fn new_from_bytes(buf: Bytes) -> Result<OwnedFB<T>, InvalidFlatbuffer>where
T: Verifiable + Follow<'static> + 'static,
pub fn new_from_bytes(buf: Bytes) -> Result<OwnedFB<T>, InvalidFlatbuffer>where
T: Verifiable + Follow<'static> + 'static,
This in practice is not zero copy. For tonic, the bytes is always shared BytesMut, so it cannot be directly turned into vec. And in general Bytes have multiple chunks, and flatbuffer need contiguous memory. So this will make a copy in most cases.
pub fn get_ref<'a>(&'a self) -> <T as Follow<'a>>::Innerwhere
T: Follow<'a>,
pub fn get_slice(&self) -> &[u8] ⓘ
Sourcepub fn into_bytes(self) -> Bytes
pub fn into_bytes(self) -> Bytes
This may be zero copy if the vec capacity equals to length and index is zero.
Auto Trait Implementations§
impl<T> Freeze for OwnedFB<T>
impl<T> RefUnwindSafe for OwnedFB<T>where
T: RefUnwindSafe,
impl<T> Send for OwnedFB<T>where
T: Send,
impl<T> Sync for OwnedFB<T>where
T: Sync,
impl<T> Unpin for OwnedFB<T>where
T: Unpin,
impl<T> UnwindSafe for OwnedFB<T>where
T: UnwindSafe,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request