Struct SqlRequest
#[non_exhaustive]pub struct SqlRequest {
pub statements: Vec<SqlStatement>,
pub isolation: IsolationLevel,
pub read_only: bool,
}Expand description
Everything one round trip carries.
A request is consumed by the round trip that sends it. That is not ceremony — it is the closest the type system gets to saying “there is no session, so this request cannot be re-sent into anything”.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.statements: Vec<SqlStatement>One statement, or several to be run server-side in one implicit transaction. Never zero.
isolation: IsolationLevelThe isolation level for the batch form.
read_only: boolWhether to ask the endpoint for a read-only transaction.
Implementations§
§impl SqlRequest
impl SqlRequest
pub fn single(statement: SqlStatement) -> Self
pub fn single(statement: SqlStatement) -> Self
A single-statement request at the default isolation level.
pub fn batch(statements: Vec<SqlStatement>, isolation: IsolationLevel) -> Self
pub fn batch(statements: Vec<SqlStatement>, isolation: IsolationLevel) -> Self
A multi-statement request, run server-side as one non-interactive transaction.
pub fn read_only(self) -> Self
pub fn read_only(self) -> Self
Marks the request read-only.
pub fn body(&self) -> Result<Vec<u8>, Error>
pub fn body(&self) -> Result<Vec<u8>, Error>
The JSON body to POST.
The endpoint takes two shapes and distinguishes them structurally: a bare
{"query": …, "params": […]} for one statement, and
{"queries": [ … ]} for the batch. An empty statements serialises as
the batch form with an empty array, which the endpoint rejects; the
adapter never builds one.
§Errors
Returns the serde_json error if a parameter cannot be serialised.