pub struct View<T>{ /* private fields */ }Expand description
Immutable view with zero-copy field derive and cloning.
Access itself is the same as accessing a &T.
Has a backing ByteOwner that retains the bytes until all views are dropped,
analogue to Bytes.
See ByteOwner for an exhaustive list and more details.
Implementations§
Source§impl<T> View<T>
impl<T> View<T>
Sourcepub unsafe fn from_raw_parts(
data: &'static T,
owner: Arc<dyn ByteOwner>,
) -> View<T>
pub unsafe fn from_raw_parts( data: &'static T, owner: Arc<dyn ByteOwner>, ) -> View<T>
Creates a view from raw parts without any checks.
§Safety
The caller must guarantee that data remains valid for the lifetime of
owner.
Sourcepub fn downcast_to_owner<O>(self) -> Result<Arc<O>, View<T>>
pub fn downcast_to_owner<O>(self) -> Result<Arc<O>, View<T>>
Returns the owner of the View in an Arc.
Source§impl<T> View<T>
impl<T> View<T>
Sourcepub fn field_to_view<F>(&self, field: &F) -> Option<View<F>>
pub fn field_to_view<F>(&self, field: &F) -> Option<View<F>>
Attempt to convert reference to a zero-copy subview of this View.
Returns None if the bytes of the child are outside the memory range of
the bytes of this view.
This is similar to Bytes::slice_to_bytes but for View.
Trait Implementations§
Source§impl<T> Ord for View<T>
impl<T> Ord for View<T>
Source§impl<T> PartialOrd for View<T>
impl<T> PartialOrd for View<T>
Source§impl ToBlob<LongString> for View<str>
impl ToBlob<LongString> for View<str>
Source§fn to_blob(self) -> Blob<LongString>
fn to_blob(self) -> Blob<LongString>
Converts this value into a blob.
Source§impl TryFromBlob<LongString> for View<str>
impl TryFromBlob<LongString> for View<str>
impl<T> Eq for View<T>
impl<T> Send for View<T>
impl<T> Sync for View<T>
Auto Trait Implementations§
impl<T> Freeze for View<T>where
T: ?Sized,
impl<T> !RefUnwindSafe for View<T>
impl<T> Unpin for View<T>where
T: ?Sized,
impl<T> UnsafeUnpin for View<T>where
T: ?Sized,
impl<T> !UnwindSafe for View<T>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)