pub struct Response<E: EntityKind>(pub Vec<Row<E>>);Expand description
Response
Materialized query result: ordered (Key, Entity) pairs.
Tuple Fields§
§0: Vec<Row<E>>Implementations§
Source§impl<E: EntityKind> Response<E>
impl<E: EntityKind> Response<E>
Sourcepub fn require_one(&self) -> Result<(), Error>
pub fn require_one(&self) -> Result<(), Error>
Require exactly one row.
Sourcepub fn require_some(&self) -> Result<(), Error>
pub fn require_some(&self) -> Result<(), Error>
Require at least one row.
Sourcepub fn into_page(self, limit: usize) -> Page<E>
pub fn into_page(self, limit: usize) -> Page<E>
Convert the response into a page of entities with a has_more indicator.
This consumes at most limit + 1 rows to determine whether more results
exist. Ordering is preserved.
NOTE:
has_moreonly indicates the existence of additional rows- Page boundaries are not stable unless the underlying query ordering is stable
Sourcepub fn one_opt_key(self) -> Result<Option<Key>, Error>
pub fn one_opt_key(self) -> Result<Option<Key>, Error>
Require at most one row and return its key.
pub fn contains_key(&self, key: &Key) -> bool
Sourcepub fn one_entity(self) -> Result<E, Error>
pub fn one_entity(self) -> Result<E, Error>
Require exactly one entity.
Sourcepub fn one_opt_entity(self) -> Result<Option<E>, Error>
pub fn one_opt_entity(self) -> Result<Option<E>, Error>
Require at most one entity.
Sourcepub fn pk(&self) -> Option<E::PrimaryKey>
pub fn pk(&self) -> Option<E::PrimaryKey>
First primary key in the response, if present.
Sourcepub fn pks(&self) -> Vec<E::PrimaryKey>
pub fn pks(&self) -> Vec<E::PrimaryKey>
Collect all primary keys in order.
Sourcepub fn one_pk(self) -> Result<E::PrimaryKey, Error>
pub fn one_pk(self) -> Result<E::PrimaryKey, Error>
Require exactly one primary key.
Sourcepub fn one_opt_pk(self) -> Result<Option<E::PrimaryKey>, Error>
pub fn one_opt_pk(self) -> Result<Option<E::PrimaryKey>, Error>
Require at most one primary key.
Sourcepub fn view(self) -> Option<E::ViewType>
pub fn view(self) -> Option<E::ViewType>
Convert the first entity to its view type, if present.
Sourcepub fn first(self) -> Option<Row<E>>
pub fn first(self) -> Option<Row<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.
Sourcepub fn first_entity(self) -> Option<E>
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.
Sourcepub fn first_pk(self) -> Option<E::PrimaryKey>
pub fn first_pk(self) -> Option<E::PrimaryKey>
Return the first primary key in the response, if any.
This does NOT enforce cardinality.