Rows

Enum Rows 

Source
pub enum Rows {
    Count(u64),
    Value(Value),
    Stream(ValueStream),
}
Expand description

The payload of an ExecResponse.

Operations that modify rows typically return Count. Queries return either a single Value or a Stream of rows.

Variants§

§

Count(u64)

Number of rows affected by the operation (e.g., rows deleted or updated).

§

Value(Value)

A single value result.

§

Stream(ValueStream)

A stream of result rows, consumed asynchronously.

Implementations§

Source§

impl Rows

Source

pub fn value_stream(values: impl Into<ValueStream>) -> Self

Wraps the given values as a Stream.

Source

pub fn is_count(&self) -> bool

Returns true if this is a Count variant.

Source

pub async fn buffer(&mut self) -> Result<()>

If this is a Stream, collects all values and converts it to a Value containing a Value::List. Other variants are left unchanged.

Source

pub async fn dup(&mut self) -> Result<Self>

Creates a duplicate of this Rows value.

For streams, this buffers the stream contents so both the original and the duplicate can be consumed independently.

Source

pub fn try_clone(&self) -> Option<Self>

Attempts to clone this Rows value without async buffering.

Returns None if the stream variant cannot be cloned synchronously.

Source

pub fn into_count(self) -> u64

Consumes this Rows and returns the count.

§Panics

Panics if this is not a Count variant.

Source

pub async fn collect_as_value(self) -> Result<Value>

Collects all rows into a single Value::List.

For Stream variants, this consumes the entire stream. For Value variants, returns the value directly.

§Panics

Panics if this is a Count variant.

Source

pub fn into_value_stream(self) -> ValueStream

Converts this Rows into a ValueStream.

Value::List variants are converted into a stream from the list items.

§Panics

Panics if this is a Count variant.

Trait Implementations§

Source§

impl Debug for Rows

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Rows

§

impl !RefUnwindSafe for Rows

§

impl Send for Rows

§

impl !Sync for Rows

§

impl Unpin for Rows

§

impl !UnwindSafe for Rows

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