Skip to main content

AnyRowExt

Trait AnyRowExt 

Source
pub trait AnyRowExt {
    // Required methods
    fn get_bool(&self, column: &str) -> Result<bool, Error>;
    fn get_text(&self, column: &str) -> Result<String, Error>;
    fn get_text_opt(&self, column: &str) -> Result<Option<String>, Error>;
    fn get_int(&self, column: &str) -> Result<i64, Error>;
    fn get_int_opt(&self, column: &str) -> Result<Option<i64>, Error>;
}
Expand description

Row helpers for portably stored types.

Required Methods§

Source

fn get_bool(&self, column: &str) -> Result<bool, Error>

Reads a boolean stored as a 0/1 integer (the portable representation, see bind_values). The counterpart to binding a bool.

Source

fn get_text(&self, column: &str) -> Result<String, Error>

Reads a text column as a String, portably. MySQL reports TEXT columns as BLOB through sqlx::Any, so a plain String decode fails there; this falls back to reading the bytes and decoding UTF-8. Use for every text read so the same code works on every backend.

Source

fn get_text_opt(&self, column: &str) -> Result<Option<String>, Error>

The nullable counterpart to [get_text], for a text column that may be NULL.

Source

fn get_int(&self, column: &str) -> Result<i64, Error>

Reads an integer column as i64, portably. sqlx::Any reports SQLite integers as i64 but Postgres INTEGER as i32, so a fixed width fails on one backend; this tries i64 then falls back to i32. Use for any integer column whatever its declared width, so a column need not be widened to bigint just to be read back.

Source

fn get_int_opt(&self, column: &str) -> Result<Option<i64>, Error>

The nullable counterpart to [get_int].

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl AnyRowExt for AnyRow

Source§

fn get_bool(&self, column: &str) -> Result<bool, Error>

Source§

fn get_text(&self, column: &str) -> Result<String, Error>

Source§

fn get_text_opt(&self, column: &str) -> Result<Option<String>, Error>

Source§

fn get_int(&self, column: &str) -> Result<i64, Error>

Source§

fn get_int_opt(&self, column: &str) -> Result<Option<i64>, Error>

Implementors§