pub trait Row:
Sealed
+ Unpin
+ Send
+ Sync
+ 'static {
type Database: Database;
// Required methods
fn columns(&self) -> &[<Self::Database as Database>::Column];
fn try_get_raw<I>(
&self,
index: I,
) -> Result<<Self::Database as HasValueRef<'_>>::ValueRef, Error>
where I: ColumnIndex<Self>;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn len(&self) -> usize { ... }
fn column<I>(&self, index: I) -> &<Self::Database as Database>::Column
where I: ColumnIndex<Self> { ... }
fn try_column<I>(
&self,
index: I,
) -> Result<&<Self::Database as Database>::Column, Error>
where I: ColumnIndex<Self> { ... }
fn get<'r, T, I>(&'r self, index: I) -> T
where I: ColumnIndex<Self>,
T: Decode<'r, Self::Database> + Type<Self::Database> { ... }
fn get_unchecked<'r, T, I>(&'r self, index: I) -> T
where I: ColumnIndex<Self>,
T: Decode<'r, Self::Database> { ... }
fn try_get<'r, T, I>(&'r self, index: I) -> Result<T, Error>
where I: ColumnIndex<Self>,
T: Decode<'r, Self::Database> + Type<Self::Database> { ... }
fn try_get_unchecked<'r, T, I>(&'r self, index: I) -> Result<T, Error>
where I: ColumnIndex<Self>,
T: Decode<'r, Self::Database> { ... }
}
Expand description
Represents a single row from the database.
This trait is sealed and cannot be implemented for types outside of SQLx.
Required Associated Typesยง
Required Methodsยง
Sourcefn columns(&self) -> &[<Self::Database as Database>::Column]
fn columns(&self) -> &[<Self::Database as Database>::Column]
Gets all columns in this statement.
Sourcefn try_get_raw<I>(
&self,
index: I,
) -> Result<<Self::Database as HasValueRef<'_>>::ValueRef, Error>where
I: ColumnIndex<Self>,
fn try_get_raw<I>(
&self,
index: I,
) -> Result<<Self::Database as HasValueRef<'_>>::ValueRef, Error>where
I: ColumnIndex<Self>,
Index into the database row and decode a single value.
ยงErrors
ColumnNotFound
if the column by the given name was not found.ColumnIndexOutOfBounds
if theusize
index was greater than the number of columns in the row.
Provided Methodsยง
Sourcefn column<I>(&self, index: I) -> &<Self::Database as Database>::Columnwhere
I: ColumnIndex<Self>,
fn column<I>(&self, index: I) -> &<Self::Database as Database>::Columnwhere
I: ColumnIndex<Self>,
Gets the column information at index
.
A string index can be used to access a column by name and a usize
index
can be used to access a column by position.
ยงPanics
Panics if index
is out of bounds.
See try_column
for a non-panicking version.
Sourcefn try_column<I>(
&self,
index: I,
) -> Result<&<Self::Database as Database>::Column, Error>where
I: ColumnIndex<Self>,
fn try_column<I>(
&self,
index: I,
) -> Result<&<Self::Database as Database>::Column, Error>where
I: ColumnIndex<Self>,
Gets the column information at index
or None
if out of bounds.
Sourcefn get<'r, T, I>(&'r self, index: I) -> T
fn get<'r, T, I>(&'r self, index: I) -> T
Index into the database row and decode a single value.
A string index can be used to access a column by name and a usize
index
can be used to access a column by position.
ยงPanics
Panics if the column does not exist or its value cannot be decoded into the requested type.
See try_get
for a non-panicking version.
Sourcefn get_unchecked<'r, T, I>(&'r self, index: I) -> T
fn get_unchecked<'r, T, I>(&'r self, index: I) -> T
Index into the database row and decode a single value.
Unlike get
, this method does not check that the type
being returned from the database is compatible with the Rust type and blindly tries
to decode the value.
ยงPanics
Panics if the column does not exist or its value cannot be decoded into the requested type.
See try_get_unchecked
for a non-panicking version.
Sourcefn try_get<'r, T, I>(&'r self, index: I) -> Result<T, Error>
fn try_get<'r, T, I>(&'r self, index: I) -> Result<T, Error>
Index into the database row and decode a single value.
A string index can be used to access a column by name and a usize
index
can be used to access a column by position.
ยงErrors
ColumnNotFound
if the column by the given name was not found.ColumnIndexOutOfBounds
if theusize
index was greater than the number of columns in the row.ColumnDecode
if the value could not be decoded into the requested type.
Sourcefn try_get_unchecked<'r, T, I>(&'r self, index: I) -> Result<T, Error>
fn try_get_unchecked<'r, T, I>(&'r self, index: I) -> Result<T, Error>
Index into the database row and decode a single value.
Unlike try_get
, this method does not check that the type
being returned from the database is compatible with the Rust type and blindly tries
to decode the value.
ยงErrors
ColumnNotFound
if the column by the given name was not found.ColumnIndexOutOfBounds
if theusize
index was greater than the number of columns in the row.ColumnDecode
if the value could not be decoded into the requested type.
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.