Struct Str

Source
pub struct Str(/* private fields */);
Expand description

Subtype of Value that represents a string

Implementations§

Source§

impl Str

Source

pub fn substr(&self, index: RangeInclusive<&Value>) -> Result<&str, Error>

String indexing Returns a substring

Although this looks like the IndexingOperationExt trait, it is not because it returns a string instead of a value

Source

pub fn mut_substr( &mut self, index: RangeInclusive<&Value>, ) -> Result<&mut str, Error>

Mutable string indexing Returns a mutable substring

Although this looks like the IndexingOperationExt trait, it is not because it returns a string instead of a value

Source

pub fn set_substr( &mut self, index: RangeInclusive<&Value>, value: Value, ) -> Result<(), Error>

Replace a set of characters in the string

Although this looks like the IndexingOperationExt trait, it is not because it returns a string instead of a value

Source

pub fn index_value_to_range( index: &Value, ) -> Result<RangeInclusive<Value>, Error>

Convert an index value to a range, useful for bridging the gap between the IndexingOperationExt trait and the substr functions Can fail if the index is not an array of integers, or if the array is empty

Source

pub fn to_escaped_string(&self) -> String

Returns a quoted string, with , \n, \r, \t and “ escaped

Trait Implementations§

Source§

impl Add for Str

Source§

type Output = Result<Str, Error>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl ArithmeticOperationExt for Str

Source§

fn arithmetic_op( self, right: Self, operation: ArithmeticOperation, ) -> Result<Self, Error>

Perform an arithmetic operation on two values If the operation is not supported on the given type, an Error::UnsupportedOperation will be returned Read more
Source§

fn arithmetic_neg(self) -> Result<Self, Error>
where Self: Sized,

Perform an arithmetic negation on a value This is equivalent to arithmetic_op with ArithmeticOperation::Negate but is provided for convenience Read more
Source§

impl BooleanOperationExt for Str

Source§

fn boolean_op( self, right: Self, operation: BooleanOperation, ) -> Result<Value, Error>

Perform a boolean operation on two values If the operation is not supported on the given type, an Error::UnsupportedOperation will be returned Read more
Source§

fn boolean_not(self) -> Result<Value, Error>
where Self: Sized,

Perform a boolean not on a value This is equivalent to boolean_op with BooleanOperation::Not but is provided for convenience Read more
Source§

impl Clone for Str

Source§

fn clone(&self) -> Str

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Str

Source§

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

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

impl Default for Str

Source§

fn default() -> Str

Returns the “default value” for a type. Read more
Source§

impl DerefMut for Str

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'de> Deserialize<'de> for Str

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Str

Source§

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

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

impl From<&str> for Str

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl From<Str> for Value

Source§

fn from(v: Str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Str

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl Hash for Str

Source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IndexingOperationExt for Str

Source§

fn get_index(&self, index: &Value) -> Result<Value, Error>

Get a value from an index Returns a value, or an Error::Index if the index is not found Read more
Source§

fn get_indices(&self, index: &Value) -> Result<Value, Error>

Get values from one or more indices Returns a vector of values, or an Error::Index if any of the indices are not found Read more
Source§

impl Into<String> for Str

Source§

fn into(self) -> String

Converts this type into the (usually inferred) input type.
Source§

impl MatchingOperationExt for Str

Source§

fn matching_op( container: &Self, pattern: &Value, operation: MatchingOperation, ) -> Result<Value, Error>
where Self: Sized,

Perform a matching operation on two values If the operation is not supported on the given type, an Error::UnsupportedOperation will be returned Read more
Source§

impl Neg for Str

Source§

type Output = Result<Str, Error>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Ord for Str

Source§

fn cmp(&self, other: &Str) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Str

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Str

Source§

fn partial_cmp(&self, other: &Str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Str

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Sub for Str

Source§

type Output = Result<Str, Error>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl TryFrom<Array> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Bool> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Bool) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Currency> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Currency) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Fixed> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Fixed) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Float> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Float) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<I16> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: I16) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<I32> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: I32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<I64> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: I64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<I8> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: I8) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Object> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Object) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for Array

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for Bool

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for Currency

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for Fixed

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for Float

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for I16

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for I32

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for I64

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for I8

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for Object

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for Range

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for U16

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for U32

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for U64

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Str> for U8

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<U16> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: U16) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<U32> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: U32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<U64> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: U64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<U8> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: U8) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Str

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl ValueTrait for Str

Source§

type Inner = String

The inner type of the value
Source§

fn new(inner: String) -> Self

Creates a new value from the given inner value
Source§

fn inner(&self) -> &String

Returns a reference to the inner value
Source§

fn inner_mut(&mut self) -> &mut String

Returns a mutable reference to the inner value
Source§

fn into_inner(self) -> String

Consumes the value and returns the inner value
Source§

impl Deref for Str

Source§

type Target = <Str as ValueTrait>::Inner

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Eq for Str

Source§

impl StructuralPartialEq for Str

Auto Trait Implementations§

§

impl Freeze for Str

§

impl RefUnwindSafe for Str

§

impl Send for Str

§

impl Sync for Str

§

impl Unpin for Str

§

impl UnwindSafe for Str

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> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,