Struct hdbconnect::ResultSet [−][src]
pub struct ResultSet { /* fields omitted */ }
Contains the result of a database read command, including the describing metadata.
In most cases, you will want to use the powerful method
try_into
to convert the data from the generic format
into your application specific format.
Methods
impl ResultSet
[src]
impl ResultSet
pub fn total_number_of_rows(&mut self) -> HdbResult<usize>
[src]
pub fn total_number_of_rows(&mut self) -> HdbResult<usize>
Returns the total number of rows in the resultset, including those that still need to be fetched from the database, but excluding those that have already been removed from the resultset.
This method can be expensive, and it can fail, since it fetches all yet outstanding rows from the database.
pub fn pop_row(&mut self) -> Option<Row>
[src]
pub fn pop_row(&mut self) -> Option<Row>
Removes the last row and returns it, or None if it is empty.
pub fn has_multiple_rows(&mut self) -> bool
[src]
pub fn has_multiple_rows(&mut self) -> bool
Returns true if more than 1 row is contained
pub fn reverse_rows(&mut self)
[src]
pub fn reverse_rows(&mut self)
Reverses the order of the rows
pub fn metadata(&self) -> &ResultSetMetadata
[src]
pub fn metadata(&self) -> &ResultSetMetadata
Access to metadata.
pub fn fetch_all(&mut self) -> HdbResult<()>
[src]
pub fn fetch_all(&mut self) -> HdbResult<()>
Fetches all not yet transported result lines from the server.
Bigger resultsets are typically not transported in one DB roundtrip; the number of roundtrips depends on the size of the resultset and the configured fetch_size of the connection.
pub fn accumulated_server_processing_time(&self) -> i32
[src]
pub fn accumulated_server_processing_time(&self) -> i32
Returns the accumulated server processing time of the calls that produced this resultset, i.e. the initial call and potentially a subsequent number of fetches.
pub fn try_into<'de, T>(self) -> HdbResult<T> where
T: Deserialize<'de>,
[src]
pub fn try_into<'de, T>(self) -> HdbResult<T> where
T: Deserialize<'de>,
Translates a generic resultset into a given rust type that implements serde::Deserialize. The implementation of this function uses serde_db. See there for more details.
A resultset is essentially a two-dimensional structure, given as a list
of rows (a Vec<Row>
),
where each row is a list of fields (a
Vec<TypedValue>
); the name of each field is
given in the metadata of the resultset.
The method supports a variety of target data structures, with the only strong limitation that no data loss is supported.
-
It depends on the dimension of the resultset what target data structure you can choose for deserialization:
- You can always use a
Vec<line_struct>
, whereline_struct
matches the field list of the resultset.
- You can always use a
-
If the resultset contains only a single line (e.g. because you specified TOP 1 in your select), then you can optionally choose to deserialize into a plain
line_struct
. -
If the resultset contains only a single column, then you can optionally choose to deserialize into a
Vec<plain_field>
. -
If the resultset contains only a single value (one row with one column), then you can optionally choose to deserialize into a plain
line_struct
, or aVec<plain_field>
, or a plain variable. -
Also the translation of the individual field values provides a lot of flexibility. You can e.g. convert values from a nullable column into a plain field, provided that no NULL values are given in the resultset.
Vice versa, you always can use an
Option<plain_field>
, even if the column is
marked as NOT NULL.
- Similarly, integer types can differ, as long as the concrete values can be assigned without loss.
Note that you need to specify the type of your target variable
explicitly, so that try_into()
can derive the type it
needs to serialize into:
#[derive(Deserialize)] struct MyStruct { ... } let typed_result: Vec<MyStruct> = resultset.try_into()?;
Trait Implementations
impl Debug for ResultSet
[src]
impl Debug for ResultSet
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Display for ResultSet
[src]
impl Display for ResultSet
fn fmt(&self, fmt: &mut Formatter) -> Result
[src]
fn fmt(&self, fmt: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl IntoIterator for ResultSet
[src]
impl IntoIterator for ResultSet