pub struct Row<'a> { /* private fields */ }Expand description
Input Block data row
Implementations§
Source§impl<'a> Row<'a>
impl<'a> Row<'a>
Sourcepub unsafe fn create(block: &'a ServerBlock, row_index: u64) -> Row<'a>
pub unsafe fn create(block: &'a ServerBlock, row_index: u64) -> Row<'a>
§Safety
This function should be called after
row_index parameter was checked against row array boundary
Block Iterators check it
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of columns This number must correspond to the number of fields in the SELECT statement
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Empty server Data block is the special type of message. It’s used internally and usually cannot be returned to user
pub fn iter_columns(&self) -> Iter<'_, BlockColumn>
pub fn iter_values(&self) -> Iter<'_, ValueRef<'_>>
Sourcepub fn value<T>(&'a self, index: usize) -> Result<Option<T>>where
T: 'a,
ValueRef<'a>: Value<'a, T>,
pub fn value<T>(&'a self, index: usize) -> Result<Option<T>>where
T: 'a,
ValueRef<'a>: Value<'a, T>,
Returns row field value converting underlying Sql type to rust data type if the specific conversion is available. Otherwise it returns ConversionError For nullable Sql types if the field contains null value this method returns Ok(None)
Examples found in repository?
27 fn deserialize(row: Row) -> errors::Result<Self> {
28 let err = || errors::ConversionError::UnsupportedConversion;
29
30 let id: u64 = row.value(0)?.ok_or_else(err)?;
31 let url: &str = row.value(1)?.ok_or_else(err)?;
32 let date: ServerDate = row.value(2)?.ok_or_else(err)?;
33 let client: Uuid = row.value(3)?.ok_or_else(err)?;
34 let ip = row.value(4)?.ok_or_else(err)?;
35 let value: Decimal32 = row.value(5)?.ok_or_else(err)?;
36
37 Ok(Blob {
38 id,
39 date,
40 client,
41 value,
42 url: url.to_string(),
43 ip,
44 })
45 }Sourcepub unsafe fn value_unchecked<T>(&'a self, index: usize) -> Option<T>where
T: 'a,
ValueRef<'a>: Value<'a, T>,
pub unsafe fn value_unchecked<T>(&'a self, index: usize) -> Option<T>where
T: 'a,
ValueRef<'a>: Value<'a, T>,
The same as value method but without performing any checking.
§Safety
Calling this method with an out of bound ‘index’ value is UB. Panic if this method is called with unsupported data conversion At the moment the driver provides limited number of data conversions. This method should be used only if you know that table data structure will nether change and you know exactly data types every column of the query.
pub fn column_descr(&self, index: usize) -> Option<&BlockColumn>
Sourcepub fn column_index(&self, name: &str) -> usize
pub fn column_index(&self, name: &str) -> usize
Returns column index by its name
Sourcepub fn deserialize<D: Deserialize>(self) -> Result<D>
pub fn deserialize<D: Deserialize>(self) -> Result<D>
Perform transformation Row to Plain object. Requires that object type implements Deserialize trait