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]

[src]

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.

[src]

Removes the last row and returns it, or None if it is empty.

[src]

Returns true if more than 1 row is contained

[src]

Reverses the order of the rows

[src]

Access to metadata.

[src]

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.

[src]

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.

[src]

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>, where line_struct matches the field list of the resultset.

    • 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 a Vec<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:

Be careful when using this code, it's not being tested!
#[derive(Deserialize)]
struct MyStruct {
    ...
}
let typed_result: Vec<MyStruct> = resultset.try_into()?;

Trait Implementations

impl Debug for ResultSet
[src]

[src]

Formats the value using the given formatter.

impl Display for ResultSet
[src]

[src]

Formats the value using the given formatter. Read more

impl IntoIterator for ResultSet
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more