Type Alias freya_engine::prelude::Data
pub type Data = RCHandle<SkData>;
Aliased Type§
struct Data(/* private fields */);
Implementations
§impl RCHandle<SkData>
impl RCHandle<SkData>
pub fn size(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn copy_range(&self, offset: usize, buffer: &mut [u8]) -> &RCHandle<SkData>
pub fn new_copy(data: &[u8]) -> RCHandle<SkData>
pub unsafe fn new_bytes(data: &[u8]) -> RCHandle<SkData>
pub unsafe fn new_bytes(data: &[u8]) -> RCHandle<SkData>
Constructs Data from a given byte slice without copying it.
Users must make sure that the underlying slice will outlive the lifetime of the Data.
pub unsafe fn new_uninitialized(length: usize) -> RCHandle<SkData>
pub fn new_zero_initialized(length: usize) -> RCHandle<SkData>
pub fn new_subset( data: &RCHandle<SkData>, offset: usize, length: usize, ) -> RCHandle<SkData>
pub fn new_str(str: impl AsRef<str>) -> RCHandle<SkData>
pub fn new_str(str: impl AsRef<str>) -> RCHandle<SkData>
Constructs Data from a copy of a &str.
Functions that use Data
as a string container usually expect it to contain a c-string
including the terminating 0 byte, so this function converts the Rust str
to a CString
and calls [Self::new_cstr()
].
pub fn new_cstr(cstr: &CStr) -> RCHandle<SkData>
pub fn new_cstr(cstr: &CStr) -> RCHandle<SkData>
Constructs Data from a &CStr by copying its contents.
pub fn from_filename(path: impl AsRef<Path>) -> Option<RCHandle<SkData>>
pub fn from_filename(path: impl AsRef<Path>) -> Option<RCHandle<SkData>>
Create a new Data
referencing the file with the specified path. If the file cannot be
opened, the path contains 0 bytes, or the path is not valid UTF-8, this returns None
.
This function opens the file as a memory mapped file for the lifetime of Data
returned.
pub fn from_stream(stream: impl Read, size: usize) -> Option<RCHandle<SkData>>
pub fn from_stream(stream: impl Read, size: usize) -> Option<RCHandle<SkData>>
Attempt to read size bytes into a Data
. If the read succeeds, return the data,
else return None
. Either way the stream’s cursor may have been changed as a result
of calling read().
pub fn new_empty() -> RCHandle<SkData>
§impl<T> RCHandle<T>where
T: NativeRefCounted + NodeSubtype,
impl<T> RCHandle<T>where
T: NativeRefCounted + NodeSubtype,
pub fn as_base(&self) -> &RCHandle<<T as NodeSubtype>::Base>
pub fn as_base_mut(&mut self) -> &mut RCHandle<<T as NodeSubtype>::Base>
Trait Implementations
§impl<H> ConditionallySend for RCHandle<H>where
H: NativeRefCountedBase,
impl<H> ConditionallySend for RCHandle<H>where
H: NativeRefCountedBase,
RCHandle<H>
is conditionally Send and can be sent to
another thread when its reference count is 1.
§impl<N> Debug for RCHandle<N>where
N: NativeRefCounted,
RCHandle<N>: DebugAttributes,
impl<N> Debug for RCHandle<N>where
N: NativeRefCounted,
RCHandle<N>: DebugAttributes,
§impl<T> Deref for RCHandle<T>where
T: NativeRefCounted + NodeSubtype,
impl<T> Deref for RCHandle<T>where
T: NativeRefCounted + NodeSubtype,
§impl<T> DerefMut for RCHandle<T>where
T: NativeRefCounted + NodeSubtype,
impl<T> DerefMut for RCHandle<T>where
T: NativeRefCounted + NodeSubtype,
This implementation of DerefMut
causes subsequent UB when the containing
[RCHandle
] gets overwritten by a base type that does not match the actual
underlying type.
§impl<N> Flattenable for RCHandle<N>where
N: NativeFlattenable + NativeRefCountedBase,
impl<N> Flattenable for RCHandle<N>where
N: NativeFlattenable + NativeRefCountedBase,
§impl<N> From<&RCHandle<N>> for RCHandle<N>where
N: NativeRefCounted,
impl<N> From<&RCHandle<N>> for RCHandle<N>where
N: NativeRefCounted,
A reference counted handle is cheap to clone, so we do support a conversion from a reference to a ref counter to an owned handle.