Skip to main content

ValueFormatter

Struct ValueFormatter 

Source
pub struct ValueFormatter;
Expand description

ValueFormatter provides cqlsh-compatible string formatting for CQL values

Implementations§

Source§

impl ValueFormatter

Source

pub fn is_null(value: &Value) -> bool

Returns true when the value represents a genuine CQL NULL.

This is the authoritative null predicate used by output writers to decide whether to emit an empty CSV field. It replaces the fragile format_value(v) == "null" sentinel, which wrongly collapsed a literal text value "null" to an empty field (issue #1499).

A genuine null in a frozen column is represented as Value::Frozen(Box::new(Value::Null)) (which format_value renders as the bare string "null"), so is_null unwraps Value::Frozen recursively before checking for Value::Null. This restores the pre-#1499 CSV null-output contract for frozen columns without re-introducing the original bug: a literal text value Value::text("null") is NOT null and still emits "null". Value::Null and Value::Frozen(..) are the only genuine-null representations that format to the bare string "null" (a UDT/collection with null members formats as {field: null}/[null], not "null").

Source

pub fn format_into(value: &Value, out: &mut String)

Append the formatted string representation of value to out.

Byte-for-byte identical to format_value, but writes into a caller-owned scratch buffer so hot loops (CSV rows) can reuse one allocation across all cells instead of allocating a fresh String per cell (issue #1499). Scalar hot paths are written directly; rarer complex types delegate to format_value for a single append.

Source

pub fn format_uuid_into(bytes: &[u8; 16], out: &mut String)

Encode a 16-byte UUID as lowercase hyphenated text into out using a hex lookup table (no per-cell format! machinery). Shared by format_uuid and the JSON writer (issue #1499).

Source

pub fn format_value(value: &Value) -> String

Format a Value to its string representation according to the contract specification

§Contract Guarantees
  • UUID/TimeUUID: lowercase hyphenated (e.g., “a8f167f0-ebe7-4f20-a386-31ff138bec3b”)
  • Timestamps: YYYY-MM-DD HH:MM:SS[.fff][+0000], default UTC
  • Collections: list [a, b], set {a, b}, map {k: v}
  • Blob: 0x-prefixed lowercase hex
  • Boolean: true/false
  • Numbers: standard Rust formatting, avoid scientific notation unless necessary

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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> 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