Struct libafl_bolts::ownedref::OwnedSlice

source ·
pub struct OwnedSlice<'a, T: 'a + Sized> { /* private fields */ }
Expand description

Wrap a slice and convert to a Vec on serialize. We use a hidden inner enum so the public API can be safe, unless the user uses the unsafe OwnedSlice::from_raw_parts

Implementations§

source§

impl<'a, T> OwnedSlice<'a, T>

source

pub unsafe fn from_raw_parts(ptr: *const T, len: usize) -> Self

Create a new OwnedSlice from a raw pointer and length

§Safety

The pointer must be valid and point to a map of the size size_of<T>() * len The contents will be dereferenced in subsequent operations.

source

pub fn truncate(&mut self, new_len: usize) -> Option<usize>

Truncate the inner slice or vec returning the old size on success or None on failure

source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator over the slice.

Trait Implementations§

source§

impl<'a, T: Sized> AsSlice for OwnedSlice<'a, T>

source§

fn as_slice(&self) -> &[T]

Get the OwnedSlice as slice.

§

type Entry = T

Type of the entries in this slice
source§

impl<'a, T: 'a + Clone> Clone for OwnedSlice<'a, T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a, T: Debug + 'a + Sized> Debug for OwnedSlice<'a, T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, 'a, T> Deserialize<'de> for OwnedSlice<'a, T>
where T: Deserialize<'de> + 'a + Sized,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'a, T> From<&'a [T]> for OwnedSlice<'a, T>

Create a new OwnedSlice from a reference to a slice

source§

fn from(r: &'a [T]) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<&'a Vec<T>> for OwnedSlice<'a, T>

Create a new OwnedSlice from a vector reference

source§

fn from(vec: &'a Vec<T>) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<OwnedMutSlice<'a, T>> for OwnedSlice<'a, T>

Create a new OwnedSlice from a OwnedMutSlice

source§

fn from(mut_slice: OwnedMutSlice<'a, T>) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<OwnedSlice<'a, T>> for Vec<T>
where T: Clone,

Create a vector from an OwnedMutSlice, or return the owned vec.

source§

fn from(slice: OwnedSlice<'a, T>) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<Vec<T>> for OwnedSlice<'a, T>

Create a new OwnedSlice from a vector

source§

fn from(vec: Vec<T>) -> Self

Converts to this type from the input type.
source§

impl<'a, 'it, T> IntoIterator for &'it OwnedSlice<'a, T>

§

type Item = <Iter<'it, T> as Iterator>::Item

The type of the elements being iterated over.
§

type IntoIter = Iter<'it, T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, T> IntoOwned for OwnedSlice<'a, T>
where T: Sized + Clone,

source§

fn is_owned(&self) -> bool

Returns if the current type is an owned type.
source§

fn into_owned(self) -> Self

Transfer the current type into an owned type.
source§

impl<'a, T> Serialize for OwnedSlice<'a, T>
where T: Serialize + 'a + Sized,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for OwnedSlice<'a, T>

§

impl<'a, T> RefUnwindSafe for OwnedSlice<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> !Send for OwnedSlice<'a, T>

§

impl<'a, T> !Sync for OwnedSlice<'a, T>

§

impl<'a, T> Unpin for OwnedSlice<'a, T>
where T: Unpin,

§

impl<'a, T> UnwindSafe for OwnedSlice<'a, T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<Tail, T> Prepend<T> for Tail

§

type PreprendResult = Tail

The Resulting TupleList, of an Prepend::prepend() call, including the prepended entry.
source§

fn prepend(self, value: T) -> (T, <Tail as Prepend<T>>::PreprendResult)

Prepend a value to this tuple, returning a new tuple with prepended value.
source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,