[][src]Struct chromium::StableString

#[repr(C)]
pub struct StableString { /* fields omitted */ }

A struct for the parts of a String with a stable layout.

Unsafety

Because this type is primarily intended to help unsafe Rust we should discuss the precise guarantees offered:

  • Validity Invariants
    • The data layout is a *mut T, usize, usize.
  • Soundness Invariants
    • The *mut T must point to the start of a valid String allocation.
    • The first usize must be the correct length of that valid String.
    • The second usize must be the correct capacity of that valid String.
    • The memory is owned by the String and is allocated from Rust's Global Allocator.
      • You must not turn this type back into a String in a Rust runtime with a different global allocator than the one is was created with. At the moment (2020-03-06) it happens to be the case that the default Rust global allocator is process-wide on Windows / Mac / Linux.
    • The memory must contain valid UTF-8 data.

If you drop a StableString without turning it back into a StableString then the memory leaks.

#include <stdint.h>
// Identical layout to `StableString`
typedef struct {
  uint8_t *ptr;
  uintptr_t len;
  uintptr_t cap;
} StableString;

Trait Implementations

impl Debug for StableString[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Debug prints as a slice would.

impl Default for StableString[src]

fn default() -> Self[src]

Defaults to an empty vec.

let sv: StableString = StableString::default();
assert_eq!(sv.len(), 0);

impl Deref for StableString[src]

type Target = str

The resulting type after dereferencing.

impl DerefMut for StableString[src]

impl From<StableString> for String[src]

impl From<String> for StableString[src]

impl StableLayout for StableString[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.