Struct Utf8Bytes

pub struct Utf8Bytes(/* private field */);

UTF-8 wrapper for [Bytes].

An [Utf8Bytes] is always guaranteed to contain valid UTF-8.

Implementations

impl Utf8Bytes

const fn from_static(str: &'static str) -> Self

Creates from a static str.

fn as_str(&self) -> &str

Returns as a string slice.

Trait Implementations

impl Clone for Utf8Bytes

fn clone(&self) -> Utf8Bytes

impl Debug for Utf8Bytes

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

impl Default for Utf8Bytes

fn default() -> Utf8Bytes

impl Deref for Utf8Bytes

type Target = str;
fn deref(&self) -> &Self::Target
/// Example fn that takes a str slice
fn a(s: &str) {}

let data = axum::extract::ws::Utf8Bytes::from_static("foo123");

// auto-deref as arg
a(&data);

// deref to str methods
assert_eq!(data.len(), 6);

impl Display for Utf8Bytes

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

impl Eq for Utf8Bytes

impl From<&String> for Utf8Bytes

fn from(s: &String) -> Self

impl From<&str> for Utf8Bytes

fn from(s: &str) -> Self

impl From<String> for Utf8Bytes

fn from(s: String) -> Self

impl PartialEq for Utf8Bytes

fn eq(&self, other: &Utf8Bytes) -> bool

impl StructuralPartialEq for Utf8Bytes

impl TryFrom<Bytes> for Utf8Bytes

type Error = Utf8Error;
fn try_from(bytes: Bytes) -> Result<Self, Self::Error>

impl TryFrom<Vec<u8>> for Utf8Bytes

type Error = Utf8Error;
fn try_from(v: Vec<u8>) -> Result<Self, Self::Error>

impl<T> PartialEq<T> for Utf8Bytes where for<'a> &'a str: PartialEq<T>,

fn eq(&self, other: &T) -> bool
let payload = axum::extract::ws::Utf8Bytes::from_static("foo123");
assert_eq!(payload, "foo123");
assert_eq!(payload, "foo123".to_string());
assert_eq!(payload, &"foo123".to_string());
assert_eq!(payload, std::borrow::Cow::from("foo123"));

Auto Trait Implementations

impl !Freeze for Utf8Bytes

impl RefUnwindSafe for Utf8Bytes

impl Send for Utf8Bytes

impl Sync for Utf8Bytes

impl Unpin for Utf8Bytes

impl UnsafeUnpin for Utf8Bytes

impl UnwindSafe for Utf8Bytes

Blanket Implementations

impl<P, T> Receiver for Utf8Bytes where P: Deref<Target = T> + ?Sized, T: ?Sized,

type Target = T;

impl<Q, K> Equivalent<K> for Utf8Bytes where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

fn equivalent(&self, key: &K) -> bool

impl<Q, K> Equivalent<K> for Utf8Bytes where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

fn equivalent(&self, key: &K) -> bool

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for Utf8Bytes where ST: ?Sized, DT: ?Sized,

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for Utf8Bytes where ST: ?Sized, DT: ?Sized,

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

impl<T> CloneToUninit for Utf8Bytes where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Utf8Bytes

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> FromRef<T> for Utf8Bytes where T: Clone,

fn from_ref(input: &T) -> T

impl<T> Instrument for Utf8Bytes

impl<T> Read<Exclusive, BecauseExclusive> for Utf8Bytes where T: ?Sized,

impl<T> Same for Utf8Bytes

type Output = T;

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

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> ToString for Utf8Bytes where T: Display + ?Sized,

fn to_string(&self) -> String

impl<T> WithSubscriber for Utf8Bytes

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

fn into(self) -> U

Calls U::from(self).

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

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

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

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

impl<V, T> VZip<V> for Utf8Bytes where V: MultiLane<T>,

fn vzip(self) -> V