Struct libsql_client::Row
source · pub struct Row {
pub values: Vec<Value>,
pub value_map: HashMap<String, Value>,
}
Expand description
Represents a row returned from the database.
Fields§
§values: Vec<Value>
§value_map: HashMap<String, Value>
Implementations§
source§impl<'a> Row
impl<'a> Row
sourcepub fn try_get<V: TryFrom<&'a Value, Error = String>>(
&'a self,
index: usize
) -> Result<V>
pub fn try_get<V: TryFrom<&'a Value, Error = String>>( &'a self, index: usize ) -> Result<V>
Try to get a value by index from this row and convert it to the desired type
Will return an error if the index is invalid or if the value cannot be converted to the desired type
§Examples
let db = libsql_client::SyncClient::in_memory().unwrap();
db.execute("create table example(num integer, str text)").unwrap();
db.execute("insert into example (num, str) values (0, 'zero')").unwrap();
let rs = db.execute("select * from example").unwrap();
let row = &rs.rows[0]; // ResultSet returns array of Rows
let num : usize = row.try_get(0).unwrap();
let text : &str = row.try_get(1).unwrap();
sourcepub fn try_column<V: TryFrom<&'a Value, Error = String>>(
&'a self,
col: &str
) -> Result<V>
pub fn try_column<V: TryFrom<&'a Value, Error = String>>( &'a self, col: &str ) -> Result<V>
Try to get a value given a column name from this row and convert it to the desired type
Will return an error if the column name is invalid or if the value cannot be converted to the desired type
§Examples
let db = libsql_client::SyncClient::in_memory().unwrap();
db.execute("create table example(num integer, str text)").unwrap();
db.execute("insert into example (num, str) values (0, 'zero')").unwrap();
let rs = db.execute("select * from example").unwrap();
let row = &rs.rows[0]; // ResultSet returns array of Rows
let num : usize = row.try_column("num").unwrap();
let text : &str = row.try_column("str").unwrap();
Trait Implementations§
source§impl<'de> Deserialize<'de> for Row
impl<'de> Deserialize<'de> for Row
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl RefUnwindSafe for Row
impl Send for Row
impl Sync for Row
impl Unpin for Row
impl UnwindSafe for Row
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request