Skip to main content

SqlRequest

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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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: IsolationLevel

The isolation level for the batch form.

§read_only: bool

Whether to ask the endpoint for a read-only transaction.

Implementations§

§

impl SqlRequest

pub fn single(statement: SqlStatement) -> Self

A single-statement request at the default isolation level.

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

Marks the request read-only.

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.

pub fn headers(&self) -> Vec<(&'static str, &'static str)>

The Neon-specific headers this request needs, beyond Content-Type and the connection string.

Empty for the single-statement form: the endpoint ignores both headers there, and sending them would suggest they had an effect.

Trait Implementations§

§

impl Clone for SqlRequest

§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for SqlRequest

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.