pub struct Row {
pub columns: Vec<String>,
pub values: Vec<Value>,
}Expand description
One result row. Carries the column names plus the per-cell JSON values.
The row owns both vectors. After read returns, the
short-lived adapter is dropped; callers may keep Row values indefinitely.
Borrowed accessors (get_str_ref, get_json_ref) are tied to &self only.
Fields§
§columns: Vec<String>Column names, in the order the adapter emitted them.
Duplicate names are allowed (SQL aliases). Named getters resolve the
first occurrence left-to-right; use a positional usize index to
reach a later duplicate.
values: Vec<Value>Per-cell values, parallel to columns.
Implementations§
Source§impl Row
impl Row
Sourcepub fn get<I: RowIndex, T: DeserializeOwned>(
&self,
index: I,
) -> Result<T, DactylError>
pub fn get<I: RowIndex, T: DeserializeOwned>( &self, index: I, ) -> Result<T, DactylError>
Strict typed extraction via serde into an owned T.
- Missing column →
DactylError::ColumnNotFound. - SQL NULL into non-
OptionT→DactylError::Conversion. - SQL NULL into
Option<T>→Ok(None). - Type mismatch →
DactylError::Conversion. - Duplicate aliases → first matching column (left-to-right).
Prefer Self::get_bool for portable bools: SQLite stores booleans as
integers 0/1, which strict get::<bool> rejects. For lenient
portable shapes use Self::get_bool / Self::get_int /
Self::get_real / Self::get_str / Self::get_json.
Sourcepub fn try_get<I: RowIndex, T: DeserializeOwned>(
&self,
index: I,
) -> Result<T, DactylError>
pub fn try_get<I: RowIndex, T: DeserializeOwned>( &self, index: I, ) -> Result<T, DactylError>
Alias for Self::get. Named for callers who prefer a try_* style.
Sourcepub fn is_null<I: RowIndex>(&self, index: I) -> Result<bool, DactylError>
pub fn is_null<I: RowIndex>(&self, index: I) -> Result<bool, DactylError>
Whether the cell is SQL NULL (serde_json::Value::Null).
Missing column → DactylError::ColumnNotFound.
Sourcepub fn get_bool<I: RowIndex>(&self, index: I) -> Result<bool, DactylError>
pub fn get_bool<I: RowIndex>(&self, index: I) -> Result<bool, DactylError>
Lenient owned bool: accepts JSON true/false or integer 0/1.
NULL → DactylError::Conversion.
Sourcepub fn get_int<I: RowIndex>(&self, index: I) -> Result<i64, DactylError>
pub fn get_int<I: RowIndex>(&self, index: I) -> Result<i64, DactylError>
Lenient owned i64: accepts JSON integers (not fractional reals).
NULL → DactylError::Conversion.
Sourcepub fn get_real<I: RowIndex>(&self, index: I) -> Result<f64, DactylError>
pub fn get_real<I: RowIndex>(&self, index: I) -> Result<f64, DactylError>
Lenient owned f64: accepts any JSON number (integers and reals).
NULL → DactylError::Conversion.
Sourcepub fn get_str<I: RowIndex>(&self, index: I) -> Result<String, DactylError>
pub fn get_str<I: RowIndex>(&self, index: I) -> Result<String, DactylError>
Lenient owned String: accepts JSON string (clones the cell).
NULL → DactylError::Conversion. Prefer Self::get_str_ref to borrow.
Sourcepub fn get_str_ref<I: RowIndex>(&self, index: I) -> Result<&str, DactylError>
pub fn get_str_ref<I: RowIndex>(&self, index: I) -> Result<&str, DactylError>
Borrowed &str tied to the row lifetime. Accepts JSON string only.
NULL → DactylError::Conversion. The reference is valid while self lives.
Sourcepub fn get_json<I: RowIndex>(&self, index: I) -> Result<Value, DactylError>
pub fn get_json<I: RowIndex>(&self, index: I) -> Result<Value, DactylError>
Owned clone of the raw JSON cell (including Null).
Sourcepub fn get_json_ref<I: RowIndex>(&self, index: I) -> Result<&Value, DactylError>
pub fn get_json_ref<I: RowIndex>(&self, index: I) -> Result<&Value, DactylError>
Borrowed raw JSON cell tied to the row lifetime (including Null).