Trait Readable

Source
pub trait Readable {
    // Required methods
    fn get<T: FromSql>(&self, index: u32) -> Result<T>;
    fn get_by_name<S: Into<String>, T: FromSql>(&self, name: S) -> Result<T>;
}
Expand description

Represents a readable object, for example a set of columns or {@code OUT} parameters from a database query, later on referred to as items. Values can for columns or {@code OUT} parameters be either retrieved by specifying a name or the index. Indexes are {@code 0}-based.

Column and [OUT] parameter names used as input to getter methods are case insensitive. When a [get] method is called with a name and several items have the same name, then the value of the first matching item will be returned. Items that are not explicitly named in the query should be referenced through indexes.

For maximum portability, items within each Readable should be read in left-to-right order, and each item should be read only once.

[#get(String)] and [#get(int)] without specifying a target type returns a suitable value representation. The R2DBC specification contains a mapping table that shows default mappings between database types and Rust types. Specifying a target type, the R2DBC driver attempts to convert the value to the target type.

A item is invalidated after consumption.

Required Methods§

Source

fn get<T: FromSql>(&self, index: u32) -> Result<T>

Returns the value for a parameter.

Arguments:

  • index: the index starting at 0

return the value which can be None index out of bounds error in index is out of range (negative or equals/exceeds the number of readable objects)

Source

fn get_by_name<S: Into<String>, T: FromSql>(&self, name: S) -> Result<T>

Returns the value for a parameter.

Arguments:

  • index: the index starting at 0

return the value which can be None index out of bounds error in index is out of range (negative or equals/exceeds the number of readable objects)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§