[−][src]Struct libuv::buf::ReadonlyBuf
Readonly buffer data type.
Implementations
impl ReadonlyBuf
[src]
pub fn is_allocated(&self) -> bool
[src]
Returns true if the internal buffer is initialized
pub fn dealloc(&mut self)
[src]
Deallocate the internal buffer, but leave the Buf intact. Even though this is a "readonly" Buf, the internal storage can still be deallocated. This oddity is an unfortunate side-effect of the libuv API: for example, StreamHandle::read_start calls the allocate callback to create a Buf, then passes that Buf to the read callback as a ReadonlyBuf. You could run dealloc() in the read callback to deallocate the internal buffer - the allocate callback takes ownership of the actual Buf struct, so you don't need to worry about that.
pub fn as_c_str(&self) -> Result<&CStr, EmptyBufError>
[src]
Convert the Buf to a CStr. Returns an error if the Buf is empty. Data contained within the ReadonlyBuf must be null-terminated or this will fail!
pub fn to_string_lossy(&self) -> Result<Cow<'_, str>, EmptyBufError>
[src]
Convert the Buf to a string. Returns an error if the Buf is empty. Data contained within the ReadonlyBuf must be null-terminated or this will fail!
pub fn to_str(&self, len: usize) -> Result<&str, Box<dyn Error>>
[src]
Convert data in the Buf to a &str. Returns an error if the Buf is empty or the data is not
valid utf8. Data does not need to be null-terminated because only the first len
bytes
will be used to create the string.
Trait Implementations
impl BufTrait for ReadonlyBuf
[src]
fn readonly(&self) -> ReadonlyBuf
[src]
impl Clone for ReadonlyBuf
[src]
fn clone(&self) -> ReadonlyBuf
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for ReadonlyBuf
[src]
impl From<Buf> for ReadonlyBuf
[src]
fn from(buf: Buf) -> ReadonlyBuf
[src]
impl Index<Range<usize>> for ReadonlyBuf
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, index: Range<usize>) -> &Self::Output
[src]
impl Index<RangeFrom<usize>> for ReadonlyBuf
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, index: RangeFrom<usize>) -> &Self::Output
[src]
impl Index<RangeFull> for ReadonlyBuf
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, index: RangeFull) -> &Self::Output
[src]
impl Index<RangeInclusive<usize>> for ReadonlyBuf
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, index: RangeInclusive<usize>) -> &Self::Output
[src]
impl Index<RangeTo<usize>> for ReadonlyBuf
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, index: RangeTo<usize>) -> &Self::Output
[src]
impl Index<RangeToInclusive<usize>> for ReadonlyBuf
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, index: RangeToInclusive<usize>) -> &Self::Output
[src]
impl Index<usize> for ReadonlyBuf
[src]
Auto Trait Implementations
impl RefUnwindSafe for ReadonlyBuf
impl !Send for ReadonlyBuf
impl !Sync for ReadonlyBuf
impl Unpin for ReadonlyBuf
impl UnwindSafe for ReadonlyBuf
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,