Struct sval_json::JsonStr

source ·
pub struct JsonStr(/* private fields */);
Expand description

A string containing encoded JSON.

Streaming a JsonStr will embed its contents directly rather than treating them as a string.

Implementations§

source§

impl JsonStr

source

pub fn boxed(json: impl Into<Box<str>>) -> Box<Self>

Treat a string as native JSON.

source§

impl JsonStr

source

pub const fn new<'a>(json: &'a str) -> &'a Self

Treat a string as native JSON.

source

pub const fn as_str(&self) -> &str

Get a reference to the underlying string.

source

pub const fn as_bytes(&self) -> &[u8]

Get a reference to the bytes of the underlying string.

Trait Implementations§

source§

impl AsRef<str> for JsonStr

source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<str> for JsonStr

source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
source§

impl Debug for JsonStr

source§

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

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

impl Display for JsonStr

source§

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

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

impl<'a> From<&'a str> for &'a JsonStr

source§

fn from(value: &'a str) -> Self

Converts to this type from the input type.
source§

impl From<Box<str>> for Box<JsonStr>

source§

fn from(value: Box<str>) -> Self

Converts to this type from the input type.
source§

impl Hash for JsonStr

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
source§

impl PartialEq<str> for JsonStr

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq for JsonStr

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Value for JsonStr

source§

fn stream<'sval, S: Stream<'sval> + ?Sized>( &'sval self, stream: &mut S ) -> Result

Stream this value through a Stream.
source§

fn tag(&self) -> Option<Tag>

Get the tag of this value, if there is one.
source§

fn to_bool(&self) -> Option<bool>

Try convert this value into a boolean.
source§

fn to_f32(&self) -> Option<f32>

Try convert this value into a 32bit binary floating point number.
source§

fn to_f64(&self) -> Option<f64>

Try convert this value into a 64bit binary floating point number.
source§

fn to_i8(&self) -> Option<i8>

Try convert this value into a signed 8bit integer.
source§

fn to_i16(&self) -> Option<i16>

Try convert this value into a signed 16bit integer.
source§

fn to_i32(&self) -> Option<i32>

Try convert this value into a signed 32bit integer.
source§

fn to_i64(&self) -> Option<i64>

Try convert this value into a signed 64bit integer.
source§

fn to_i128(&self) -> Option<i128>

Try convert this value into a signed 128bit integer.
source§

fn to_u8(&self) -> Option<u8>

Try convert this value into an unsigned 8bit integer.
source§

fn to_u16(&self) -> Option<u16>

Try convert this value into an unsigned 16bit integer.
source§

fn to_u32(&self) -> Option<u32>

Try convert this value into an unsigned 32bit integer.
source§

fn to_u64(&self) -> Option<u64>

Try convert this value into an unsigned 64bit integer.
source§

fn to_u128(&self) -> Option<u128>

Try convert this value into an unsigned 128bit integer.
source§

fn to_text(&self) -> Option<&str>

Try convert this value into a text string.
source§

fn to_binary(&self) -> Option<&[u8]>

Try convert this value into a bitstring.
source§

impl Eq for JsonStr

source§

impl StructuralPartialEq for JsonStr

Auto Trait Implementations§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more