Response

Struct Response 

Source
pub struct Response<E: EntityKind>(pub Vec<(Key, E)>);
Expand description

Response Materialized query result: ordered (Key, Entity) pairs.

Tuple Fields§

§0: Vec<(Key, E)>

Implementations§

Source§

impl<E: EntityKind> Response<E>

Source

pub const fn count(&self) -> u32

Number of rows in the response, truncated to u32.

Source

pub const fn is_empty(&self) -> bool

True when no rows were returned.

Source

pub fn require_one(&self) -> Result<(), Error>

Require exactly one row.

Source

pub fn one(self) -> Result<(Key, E), Error>

Require exactly one row and return it.

Source

pub fn one_opt(self) -> Result<Option<(Key, E)>, Error>

Require at most one row and return it.

Source

pub fn key(&self) -> Option<Key>

First key in the response, if present.

Source

pub fn keys(&self) -> Vec<Key>

Collect all keys in order.

Source

pub fn one_key(self) -> Result<Key, Error>

Require exactly one row and return its key.

Source

pub fn one_opt_key(self) -> Result<Option<Key>, Error>

Require at most one row and return its key.

Source

pub fn contains_key(&self, key: &Key) -> bool

Source

pub fn entity(self) -> Option<E>

Consume the response and return the first entity, if any.

Source

pub fn entities(self) -> Vec<E>

Consume the response and collect all entities.

Source

pub fn one_entity(self) -> Result<E, Error>

Require exactly one entity.

Source

pub fn one_opt_entity(self) -> Result<Option<E>, Error>

Require at most one entity.

Source

pub fn pk(&self) -> Option<E::PrimaryKey>

First primary key in the response, if present.

Source

pub fn pks(&self) -> Vec<E::PrimaryKey>

Collect all primary keys in order.

Source

pub fn one_pk(self) -> Result<E::PrimaryKey, Error>

Require exactly one primary key.

Source

pub fn one_opt_pk(self) -> Result<Option<E::PrimaryKey>, Error>

Require at most one primary key.

Source

pub fn view(self) -> Option<E::ViewType>

Convert the first entity to its view type, if present.

Source

pub fn one_view(self) -> Result<E::ViewType, Error>

Require exactly one view.

Source

pub fn one_opt_view(self) -> Result<Option<E::ViewType>, Error>

Require at most one view.

Source

pub fn views(self) -> Vec<E::ViewType>

Convert all entities to their view types.

Source

pub fn first(self) -> Option<(Key, E)>

Return the first row in the response, if any.

This does NOT enforce cardinality. Use only when row order is well-defined and uniqueness is irrelevant.

Source

pub fn first_entity(self) -> Option<E>

Return the first entity in the response, if any.

This does NOT enforce cardinality. Use only when row order is well-defined and uniqueness is irrelevant.

Source

pub fn first_pk(self) -> Option<E::PrimaryKey>

Return the first primary key in the response, if any.

This does NOT enforce cardinality.

Trait Implementations§

Source§

impl<E: Debug + EntityKind> Debug for Response<E>

Source§

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

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

impl<E: EntityKind> IntoIterator for Response<E>

Source§

type Item = (Key, E)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<<Response<E> as IntoIterator>::Item>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<E> Freeze for Response<E>

§

impl<E> RefUnwindSafe for Response<E>
where E: RefUnwindSafe,

§

impl<E> Send for Response<E>
where E: Send,

§

impl<E> Sync for Response<E>
where E: Sync,

§

impl<E> Unpin for Response<E>
where E: Unpin,

§

impl<E> UnwindSafe for Response<E>
where E: UnwindSafe,

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

Source§

type Output = T

Should always be Self
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