pub unsafe trait FetchRow: Copy {
// Required methods
unsafe fn bind_columns_to_cursor(
&mut self,
cursor: StatementRef<'_>,
) -> Result<(), Error>;
fn find_truncation(&self) -> Option<TruncationInfo>;
}
Expand description
FetchRow
s can be bound to a crate::Cursor
to enable row wise (bulk) fetching of data as
opposed to column wise fetching. Since all rows are bound to a C-API in a contigious block of
memory the row itself should be representable as such. Concretly that means that types like
String
can not be supported directly by FetchRow
s for efficient bulk fetching, due to the
fact it points to data on the heap.
This trait is implement by tuples of FetchRowMember
. In addition it can also be derived
for structs there all members implement FetchRowMember
using the Fetch
derive macro if the
optional derive feature is activated.
§Safety
- All the bound buffers need to be valid for the lifetime of the row.
- The offsets into the memory for the field representing a column, must be constant for all types of the row. This is required to make the row suitable for fetching in bulk, as only the first row is bound explicitly, and the bindings for all consequitive rows is calculated by taking the size of the row in bytes multiplied by buffer index.
Required Methods§
Sourceunsafe fn bind_columns_to_cursor(
&mut self,
cursor: StatementRef<'_>,
) -> Result<(), Error>
unsafe fn bind_columns_to_cursor( &mut self, cursor: StatementRef<'_>, ) -> Result<(), Error>
Binds the columns of the result set to members of the row.
§Safety
Caller must ensure self is alive and not moved in memory for the duration of the binding.
Sourcefn find_truncation(&self) -> Option<TruncationInfo>
fn find_truncation(&self) -> Option<TruncationInfo>
If it exists, this returns the “buffer index” of a member, which has been truncated.
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.