Response

Struct Response 

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

Response

Tuple Fields§

§0: Vec<(Key, E)>

Implementations§

Source§

impl<E> Response<E>
where E: EntityKind,

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 key(&self) -> Option<Key>

Key

First key in the response, if present.

Source

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

Return the first key or an error if no rows were returned.

Source

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

Collect all keys in order.

Source

pub fn keys_iter(self) -> impl Iterator<Item = Key>

Iterate keys without cloning entities.

Source

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

Pk

First primary key in the response, if present.

Source

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

Return the first primary key or an error if no rows were returned.

Source

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

Collect all primary keys in order.

Source

pub fn pks_iter(self) -> impl Iterator<Item = E::PrimaryKey>

Iterate primary keys without cloning entities.

Source

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

Entity

Consume the response and return the first entity.

Source

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

Return the first entity or an error if no rows were returned.

Source

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

Consume the response and collect all entities.

Source

pub fn entities_iter(self) -> impl Iterator<Item = E>

Iterate entities without materializing a Vec.

Source

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

View

Convert the first entity to its view type.

Source

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

Convert the first entity to its view type or error if empty.

Source

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

Convert all entities to their view types and collect them.

Source

pub fn views_iter(self) -> impl Iterator<Item = E::ViewType>

Iterate over view types without cloning entities.

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.