Skip to main content

Scalar

Struct Scalar 

Source
pub struct Scalar { /* private fields */ }
Expand description

A typed scalar value.

Scalars represent a single value with an associated DType. The value can be null, in which case the value method returns None.

Implementations§

Source§

impl Scalar

Source

pub fn cast(&self, target_dtype: &DType) -> VortexResult<Scalar>

Cast this scalar to another data type.

§Errors

Returns an error if the cast is not supported or if a null value is cast to a non-nullable type.

Source

pub fn into_nullable(self) -> Scalar

Cast the scalar into a nullable version of its current type.

Source§

impl Scalar

Source

pub fn bool(value: bool, nullability: Nullability) -> Self

Creates a new boolean scalar with the given value and nullability.

Source

pub fn primitive<T: NativePType + Into<PValue>>( value: T, nullability: Nullability, ) -> Self

Creates a new primitive scalar from a native value.

Source

pub fn primitive_value( value: PValue, ptype: PType, nullability: Nullability, ) -> Self

Create a PrimitiveScalar from a PValue.

Note that an explicit PType is passed since any compatible PValue may be used as the value for a primitive type.

Source

pub fn decimal( value: DecimalValue, decimal_type: DecimalDType, nullability: Nullability, ) -> Self

Creates a new decimal scalar with the given value, precision, scale, and nullability.

Source

pub fn utf8<B>(str: B, nullability: Nullability) -> Self
where B: Into<BufferString>,

Creates a new UTF-8 scalar from a string-like value.

§Panics

Panics if the input cannot be converted to a valid UTF-8 string.

Source

pub fn try_utf8<B>( str: B, nullability: Nullability, ) -> Result<Self, <B as TryInto<BufferString>>::Error>

Tries to create a new UTF-8 scalar from a string-like value.

§Errors

Returns an error if the input cannot be converted to a valid UTF-8 string.

Source

pub fn binary(buffer: impl Into<ByteBuffer>, nullability: Nullability) -> Self

Creates a new binary scalar from a byte buffer.

Source

pub fn list( element_dtype: impl Into<Arc<DType>>, children: Vec<Scalar>, nullability: Nullability, ) -> Self

Creates a new list scalar with the given element type and children.

§Panics

Panics if any child scalar has a different type than the element type, or if there are too many children.

Source

pub fn list_empty(element_dtype: Arc<DType>, nullability: Nullability) -> Self

Creates a new empty list scalar with the given element type.

Source

pub fn fixed_size_list( element_dtype: impl Into<Arc<DType>>, children: Vec<Scalar>, nullability: Nullability, ) -> Self

Creates a new fixed-size list scalar with the given element type and children.

§Panics

Panics if any child scalar has a different type than the element type, or if there are too many children.

Source

pub fn extension<V: ExtDTypeVTable + Default>( options: V::Metadata, value: Scalar, ) -> Self

Creates a new extension scalar wrapping the given storage value.

Source

pub fn extension_ref(ext_dtype: ExtDTypeRef, value: Scalar) -> Self

Creates a new extension scalar wrapping the given storage value.

§Panics

Panics if the storage dtype of ext_dtype does not match value’s dtype.

Source§

impl Scalar

Source

pub fn as_bool(&self) -> BoolScalar<'_>

Returns a view of the scalar as a boolean scalar.

§Panics

Panics if the scalar does not have a Bool type.

Source

pub fn as_bool_opt(&self) -> Option<BoolScalar<'_>>

Returns a view of the scalar as a boolean scalar if it has a boolean type.

Source

pub fn as_primitive(&self) -> PrimitiveScalar<'_>

Returns a view of the scalar as a primitive scalar.

§Panics

Panics if the scalar does not have a Primitive type.

Source

pub fn as_primitive_opt(&self) -> Option<PrimitiveScalar<'_>>

Returns a view of the scalar as a primitive scalar if it has a primitive type.

Source

pub fn as_decimal(&self) -> DecimalScalar<'_>

Returns a view of the scalar as a decimal scalar.

§Panics

Panics if the scalar does not have a Decimal type.

Source

pub fn as_decimal_opt(&self) -> Option<DecimalScalar<'_>>

Returns a view of the scalar as a decimal scalar if it has a decimal type.

Source

pub fn as_utf8(&self) -> Utf8Scalar<'_>

Returns a view of the scalar as a UTF-8 string scalar.

§Panics

Panics if the scalar does not have a Utf8 type.

Source

pub fn as_utf8_opt(&self) -> Option<Utf8Scalar<'_>>

Returns a view of the scalar as a UTF-8 string scalar if it has a UTF-8 type.

Source

pub fn as_binary(&self) -> BinaryScalar<'_>

Returns a view of the scalar as a binary scalar.

§Panics

Panics if the scalar does not have a Binary type.

Source

pub fn as_binary_opt(&self) -> Option<BinaryScalar<'_>>

Returns a view of the scalar as a binary scalar if it has a binary type.

Source

pub fn as_struct(&self) -> StructScalar<'_>

Returns a view of the scalar as a struct scalar.

§Panics

Panics if the scalar does not have a Struct type.

Source

pub fn as_struct_opt(&self) -> Option<StructScalar<'_>>

Returns a view of the scalar as a struct scalar if it has a struct type.

Source

pub fn as_list(&self) -> ListScalar<'_>

Returns a view of the scalar as a list scalar.

Note that we use ListScalar to represent both List and FixedSizeList.

§Panics

Panics if the scalar does not have a List or FixedSizeList type.

Source

pub fn as_list_opt(&self) -> Option<ListScalar<'_>>

Returns a view of the scalar as a list scalar if it has a list type.

Note that we use ListScalar to represent both List and FixedSizeList.

Source

pub fn as_extension(&self) -> ExtScalar<'_>

Returns a view of the scalar as an extension scalar.

§Panics

Panics if the scalar does not have a Extension type.

Source

pub fn as_extension_opt(&self) -> Option<ExtScalar<'_>>

Returns a view of the scalar as an extension scalar if it has an extension type.

Source§

impl Scalar

Source

pub fn from_proto_value( value: &ScalarValue, dtype: &DType, ) -> VortexResult<Self>

Creates a Scalar from a protobuf ScalarValue representation.

Note that we need to provide a DType since protobuf serialization only supports 64-bit integers, and serializing into protobuf loses that type information.

§Errors

Returns an error if type validation fails.

Source

pub fn from_proto(value: &Scalar, session: &VortexSession) -> VortexResult<Self>

Creates a Scalar from its protobuf representation.

§Errors

Returns an error if the protobuf is missing required fields or if type validation fails.

Source§

impl Scalar

Source

pub fn null(dtype: DType) -> Self

Creates a new null Scalar with the given DType.

§Panics

Panics if the given DType is non-nullable.

Source

pub fn null_native<T: NativeDType>() -> Self

Creates a new null Scalar for the given scalar type.

The resulting scalar will have a nullable version of the type’s data type.

Source

pub fn try_new(dtype: DType, value: Option<ScalarValue>) -> VortexResult<Self>

Attempts to create a new Scalar with the given DType and potentially null ScalarValue.

§Errors

Returns an error if the given DType and ScalarValue are incompatible.

Source

pub unsafe fn new_unchecked(dtype: DType, value: Option<ScalarValue>) -> Self

Creates a new Scalar with the given DType and potentially null ScalarValue without checking compatibility.

§Safety

The caller must ensure that the given DType and ScalarValue are compatible per the rules defined in Self::is_compatible.

Source

pub fn default_value(dtype: &DType) -> Self

Returns a default value for the given DType.

For nullable types, this returns a null scalar. For non-nullable and non-nested types, this returns the zero value for the type.

For non-nullable and nested types that may need null values in their children (as of right now, that is only FixedSizeList and Struct), this function will provide null default children.

See ScalarValue::zero_value for more details about “zero” values.

Source

pub fn zero_value(dtype: &DType) -> Self

Returns a non-null zero / identity value for the given DType.

See ScalarValue::zero_value for more details about “zero” values.

Source

pub fn is_compatible(dtype: &DType, value: Option<&ScalarValue>) -> bool

Check if the given ScalarValue is compatible with the given DType.

Source

pub fn eq_ignore_nullability(&self, other: &Self) -> bool

Check if two scalars are equal, ignoring nullability of the DType.

Source

pub fn into_parts(self) -> (DType, Option<ScalarValue>)

Returns the parts of the Scalar.

Source

pub fn dtype(&self) -> &DType

Returns the DType of the Scalar.

Source

pub fn value(&self) -> Option<&ScalarValue>

Returns an optional ScalarValue of the Scalar, where None means the value is null.

Source

pub fn into_value(self) -> Option<ScalarValue>

Returns the internal optional ScalarValue, where None means the value is null, consuming the Scalar.

Source

pub fn is_valid(&self) -> bool

Returns true if the Scalar has a non-null value.

Source

pub fn is_null(&self) -> bool

Returns true if the Scalar is null.

Source

pub fn is_zero(&self) -> Option<bool>

Returns true if the Scalar has a non-null zero value.

Returns None if the scalar is null, otherwise returns Some(true) if the value is zero and Some(false) otherwise.

Source

pub fn primitive_reinterpret_cast(&self, ptype: PType) -> VortexResult<Self>

Reinterprets the bytes of this scalar as a different primitive type.

§Errors

Panics if the scalar is not a primitive type or if the types have different byte widths.

Source

pub fn nbytes(&self) -> usize

Returns an ESTIMATE of the size of the scalar in bytes, uncompressed.

Note that the protobuf serialization of scalars will likely have a different (but roughly similar) length.

Source§

impl Scalar

Source

pub fn struct_(dtype: DType, children: Vec<Scalar>) -> Self

Creates a new struct scalar with the given fields.

Trait Implementations§

Source§

impl Clone for Scalar

Source§

fn clone(&self) -> Scalar

Returns a duplicate 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 Scalar

Source§

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

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

impl Display for Scalar

Source§

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

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

impl From<&[u8]> for Scalar

Source§

fn from(value: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a Scalar> for Input<'a>

Source§

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

Converts to this type from the input type.
Source§

impl From<&Scalar> for Scalar

Source§

fn from(value: &Scalar) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Scalar

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl From<Buffer<u8>> for Scalar

Source§

fn from(value: ByteBuffer) -> Self

Converts to this type from the input type.
Source§

impl From<BufferString> for Scalar

Source§

fn from(value: BufferString) -> Self

Converts to this type from the input type.
Source§

impl From<DecimalScalar<'_>> for Scalar

Source§

fn from(ds: DecimalScalar<'_>) -> Self

Converts to this type from the input type.
Source§

impl From<DecimalValue> for Scalar

Source§

fn from(value: DecimalValue) -> Self

Converts to this type from the input type.
Source§

impl From<Option<&[u8]>> for Scalar

Source§

fn from(value: Option<&[u8]>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<&str>> for Scalar

Source§

fn from(value: Option<&str>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<Buffer<u8>>> for Scalar

Source§

fn from(value: Option<ByteBuffer>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<BufferString>> for Scalar

Source§

fn from(value: Option<BufferString>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<DecimalValue>> for Scalar

Source§

fn from(value: Option<DecimalValue>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<String>> for Scalar

Source§

fn from(value: Option<String>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Option<Vec<T>>> for Scalar
where T: NativeDType, Scalar: From<T>,

Source§

fn from(vec: Option<Vec<T>>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<bool>> for Scalar

Source§

fn from(value: Option<bool>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<f16>> for Scalar

Nullable Into<Scalar> implementation for T.

Source§

fn from(value: Option<f16>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<f32>> for Scalar

Nullable Into<Scalar> implementation for T.

Source§

fn from(value: Option<f32>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<f64>> for Scalar

Nullable Into<Scalar> implementation for T.

Source§

fn from(value: Option<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<i16>> for Scalar

Nullable Into<Scalar> implementation for T.

Source§

fn from(value: Option<i16>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<i32>> for Scalar

Nullable Into<Scalar> implementation for T.

Source§

fn from(value: Option<i32>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<i64>> for Scalar

Nullable Into<Scalar> implementation for T.

Source§

fn from(value: Option<i64>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<i8>> for Scalar

Nullable Into<Scalar> implementation for T.

Source§

fn from(value: Option<i8>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<u16>> for Scalar

Nullable Into<Scalar> implementation for T.

Source§

fn from(value: Option<u16>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<u32>> for Scalar

Nullable Into<Scalar> implementation for T.

Source§

fn from(value: Option<u32>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<u64>> for Scalar

Nullable Into<Scalar> implementation for T.

Source§

fn from(value: Option<u64>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<u8>> for Scalar

Nullable Into<Scalar> implementation for T.

Source§

fn from(value: Option<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<usize>> for Scalar

Source§

fn from(value: Option<usize>) -> Self

Converts to this type from the input type.
Source§

impl From<PrimitiveScalar<'_>> for Scalar

Source§

fn from(ps: PrimitiveScalar<'_>) -> Self

Converts to this type from the input type.
Source§

impl From<Scalar> for Output

Source§

fn from(value: Scalar) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Scalar

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Vec<T>> for Scalar
where T: NativeDType, Scalar: From<T>,

Source§

fn from(vec: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Scalar

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f16> for Scalar

Non-nullable Into<Scalar> implementation for T.

Source§

fn from(value: f16) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Scalar

Non-nullable Into<Scalar> implementation for T.

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Scalar

Non-nullable Into<Scalar> implementation for T.

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Scalar

Non-nullable Into<Scalar> implementation for T.

Source§

fn from(value: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Scalar

Non-nullable Into<Scalar> implementation for T.

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Scalar

Non-nullable Into<Scalar> implementation for T.

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Scalar

Non-nullable Into<Scalar> implementation for T.

Source§

fn from(value: i8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Scalar

Non-nullable Into<Scalar> implementation for T.

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Scalar

Non-nullable Into<Scalar> implementation for T.

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Scalar

Non-nullable Into<Scalar> implementation for T.

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Scalar

Non-nullable Into<Scalar> implementation for T.

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for Scalar

Source§

fn from(value: usize) -> Self

Converts to this type from the input type.
Source§

impl Hash for Scalar

We implement Hash manually to be consistent with PartialEq. Since we ignore nullability in equality comparisons, we must also ignore it when hashing to maintain the invariant that equal values have equal hashes.

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 IndexOrd<Scalar> for dyn Array + '_

Source§

fn index_cmp(&self, idx: usize, elem: &Scalar) -> VortexResult<Option<Ordering>>

PartialOrd of the value at index idx with elem. For example, if self[idx] > elem, return Some(Greater).
Source§

fn index_len(&self) -> usize

Get the length of the underlying ordered collection
Source§

fn index_lt(&self, idx: usize, elem: &V) -> VortexResult<bool>

Source§

fn index_le(&self, idx: usize, elem: &V) -> VortexResult<bool>

Source§

fn index_gt(&self, idx: usize, elem: &V) -> VortexResult<bool>

Source§

fn index_ge(&self, idx: usize, elem: &V) -> VortexResult<bool>

Source§

impl PartialEq for Scalar

We implement PartialEq manually because we want to ignore nullability when comparing scalars. Two scalars with the same value but different nullability should be considered equal.

Source§

fn eq(&self, other: &Self) -> 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 Scalar

Source§

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

Compares two scalar values for ordering.

§Returns
  • Some(Ordering) if both scalars have the same data type (ignoring nullability)
  • None if the scalars have different data types
§Ordering Rules

When types match, the ordering follows these rules:

  • Null values are considered less than all non-null values
  • Non-null values are compared according to their natural ordering
§Examples
// Same types compare successfully
let a = Scalar::primitive(10i32, Nullability::NonNullable);
let b = Scalar::primitive(20i32, Nullability::NonNullable);
assert_eq!(a.partial_cmp(&b), Some(Ordering::Less));

// Different types return None
let int_scalar = Scalar::primitive(10i32, Nullability::NonNullable);
let str_scalar = Scalar::utf8("hello", Nullability::NonNullable);
assert_eq!(int_scalar.partial_cmp(&str_scalar), None);

// Nulls are less than non-nulls
let null = Scalar::null(DType::Primitive(PType::I32, Nullability::Nullable));
let value = Scalar::primitive(0i32, Nullability::Nullable);
assert_eq!(null.partial_cmp(&value), Some(Ordering::Less));
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 TryFrom<&Scalar> for Arc<dyn Datum>

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> Result<Arc<dyn Datum>, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Scalar> for BinaryScalar<'a>

Source§

type Error = VortexError

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

fn try_from(value: &'a Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Scalar> for BoolScalar<'a>

Source§

type Error = VortexError

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

fn try_from(value: &'a Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Scalar> for ByteBuffer

Source§

type Error = VortexError

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

fn try_from(scalar: &'a Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Scalar> for BufferString

Source§

type Error = VortexError

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

fn try_from(scalar: &'a Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Scalar> for DecimalScalar<'a>

Source§

type Error = VortexError

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

fn try_from(value: &'a Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for DecimalValue

Source§

type Error = VortexError

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

fn try_from(scalar: &Scalar) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Scalar> for ExtScalar<'a>

Source§

type Error = VortexError

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

fn try_from(value: &'a Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Scalar> for ListScalar<'a>

Source§

type Error = VortexError

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

fn try_from(value: &'a Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Scalar> for Option<ByteBuffer>

Source§

type Error = VortexError

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

fn try_from(scalar: &'a Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Scalar> for Option<BufferString>

Source§

type Error = VortexError

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

fn try_from(scalar: &'a Scalar) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for Option<DecimalValue>

Source§

type Error = VortexError

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

fn try_from(scalar: &Scalar) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for Option<bool>

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for Option<f16>

Fallible conversion from a Scalar into an Option<T>.

§Errors

Returns an error if the Scalar is not primitive, or if it is unable to convert the Scalar into the target type.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for Option<f32>

Fallible conversion from a Scalar into an Option<T>.

§Errors

Returns an error if the Scalar is not primitive, or if it is unable to convert the Scalar into the target type.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for Option<f64>

Fallible conversion from a Scalar into an Option<T>.

§Errors

Returns an error if the Scalar is not primitive, or if it is unable to convert the Scalar into the target type.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for Option<i16>

Fallible conversion from a Scalar into an Option<T>.

§Errors

Returns an error if the Scalar is not primitive, or if it is unable to convert the Scalar into the target type.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for Option<i32>

Fallible conversion from a Scalar into an Option<T>.

§Errors

Returns an error if the Scalar is not primitive, or if it is unable to convert the Scalar into the target type.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for Option<i64>

Fallible conversion from a Scalar into an Option<T>.

§Errors

Returns an error if the Scalar is not primitive, or if it is unable to convert the Scalar into the target type.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for Option<i8>

Fallible conversion from a Scalar into an Option<T>.

§Errors

Returns an error if the Scalar is not primitive, or if it is unable to convert the Scalar into the target type.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for Option<u16>

Fallible conversion from a Scalar into an Option<T>.

§Errors

Returns an error if the Scalar is not primitive, or if it is unable to convert the Scalar into the target type.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for Option<u32>

Fallible conversion from a Scalar into an Option<T>.

§Errors

Returns an error if the Scalar is not primitive, or if it is unable to convert the Scalar into the target type.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for Option<u64>

Fallible conversion from a Scalar into an Option<T>.

§Errors

Returns an error if the Scalar is not primitive, or if it is unable to convert the Scalar into the target type.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for Option<u8>

Fallible conversion from a Scalar into an Option<T>.

§Errors

Returns an error if the Scalar is not primitive, or if it is unable to convert the Scalar into the target type.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for Option<usize>

Source§

type Error = VortexError

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

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

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Scalar> for PrimitiveScalar<'a>

Source§

type Error = VortexError

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

fn try_from(value: &'a Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Scalar> for String

Source§

type Error = VortexError

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

fn try_from(value: &'a Scalar) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Scalar> for StructScalar<'a>

Source§

type Error = VortexError

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

fn try_from(value: &'a Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Scalar> for Utf8Scalar<'a>

Source§

type Error = VortexError

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

fn try_from(value: &'a Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl<'a, T> TryFrom<&'a Scalar> for Vec<T>
where T: for<'b> TryFrom<&'b Scalar, Error = VortexError>,

Source§

type Error = VortexError

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

fn try_from(value: &'a Scalar) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for bool

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for f16

Fallible conversion from a Scalar into an T.

§Errors

Returns an error if unable to convert the scalar into the target type, or if the Scalar itself is null.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for f32

Fallible conversion from a Scalar into an T.

§Errors

Returns an error if unable to convert the scalar into the target type, or if the Scalar itself is null.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for f64

Fallible conversion from a Scalar into an T.

§Errors

Returns an error if unable to convert the scalar into the target type, or if the Scalar itself is null.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for i16

Fallible conversion from a Scalar into an T.

§Errors

Returns an error if unable to convert the scalar into the target type, or if the Scalar itself is null.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for i32

Fallible conversion from a Scalar into an T.

§Errors

Returns an error if unable to convert the scalar into the target type, or if the Scalar itself is null.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for i64

Fallible conversion from a Scalar into an T.

§Errors

Returns an error if unable to convert the scalar into the target type, or if the Scalar itself is null.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for i8

Fallible conversion from a Scalar into an T.

§Errors

Returns an error if unable to convert the scalar into the target type, or if the Scalar itself is null.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for u16

Fallible conversion from a Scalar into an T.

§Errors

Returns an error if unable to convert the scalar into the target type, or if the Scalar itself is null.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for u32

Fallible conversion from a Scalar into an T.

§Errors

Returns an error if unable to convert the scalar into the target type, or if the Scalar itself is null.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for u64

Fallible conversion from a Scalar into an T.

§Errors

Returns an error if unable to convert the scalar into the target type, or if the Scalar itself is null.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for u8

Fallible conversion from a Scalar into an T.

§Errors

Returns an error if unable to convert the scalar into the target type, or if the Scalar itself is null.

Source§

type Error = VortexError

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

fn try_from(value: &Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Scalar> for usize

Source§

type Error = VortexError

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

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

Performs the conversion.
Source§

impl TryFrom<Scalar> for ByteBuffer

Source§

type Error = VortexError

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

fn try_from(scalar: Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<Scalar> for BufferString

Source§

type Error = VortexError

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

fn try_from(scalar: Scalar) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Scalar> for DecimalValue

Source§

type Error = VortexError

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

fn try_from(scalar: Scalar) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Scalar> for Option<ByteBuffer>

Source§

type Error = VortexError

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

fn try_from(scalar: Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<Scalar> for Option<BufferString>

Source§

type Error = VortexError

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

fn try_from(scalar: Scalar) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Scalar> for Option<DecimalValue>

Source§

type Error = VortexError

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

fn try_from(scalar: Scalar) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Scalar> for Option<bool>

Source§

type Error = VortexError

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

fn try_from(value: Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<Scalar> for String

Source§

type Error = VortexError

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

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

Performs the conversion.
Source§

impl<T> TryFrom<Scalar> for Vec<T>
where T: for<'b> TryFrom<&'b Scalar, Error = VortexError>,

Source§

type Error = VortexError

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

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

Performs the conversion.
Source§

impl TryFrom<Scalar> for bool

Source§

type Error = VortexError

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

fn try_from(value: Scalar) -> VortexResult<Self>

Performs the conversion.
Source§

impl Eq for Scalar

Auto Trait Implementations§

§

impl !Freeze for Scalar

§

impl !RefUnwindSafe for Scalar

§

impl Send for Scalar

§

impl Sync for Scalar

§

impl Unpin for Scalar

§

impl UnsafeUnpin for Scalar

§

impl !UnwindSafe for Scalar

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> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> DynEq for T
where T: PartialEq + 'static,

Source§

fn dyn_eq(&self, other: &(dyn Any + 'static)) -> bool

Compares self with another Any type for equality.
Source§

impl<T> DynHash for T
where T: Hash + 'static,

Source§

fn dyn_hash(&self, state: &mut dyn Hasher)

Hashes self into the given hasher.
Source§

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

Source§

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

Compare self to key and return true if they are equal.
Source§

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

Source§

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

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Paint for T
where T: ?Sized,

Source§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
Source§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
Source§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
Source§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
Source§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
Source§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
Source§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
Source§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
Source§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
Source§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
Source§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
Source§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
Source§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
Source§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
Source§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
Source§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
Source§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
Source§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
Source§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
Source§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
Source§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
Source§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
Source§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
Source§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
Source§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
Source§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
Source§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
Source§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
Source§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
Source§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
Source§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
Source§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
Source§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
Source§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
Source§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
Source§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
Source§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
Source§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
Source§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
Source§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
Source§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling Attribute value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
Source§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
Source§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
Source§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
Source§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
Source§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
Source§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
Source§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
Source§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi Quirk value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
Source§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
Source§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
Source§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
Source§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
Source§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
Source§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
Source§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
Source§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the Condition value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
Source§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new Painted with a default Style. Read more
Source§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> SessionVar for T
where T: Send + Sync + Debug + 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
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> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A> Annotation for A
where A: Clone + Hash + Eq,