pub struct Query<Args> { /* private fields */ }Expand description
A DQL query string with its arguments
Most APIs in the Ditto SDK don’t take a Query directly, but instead take a generic
parameter that implements IntoQuery, a trait implemented by types that can be turned into a
Query.
Common examples are:
String(and string-like types)(String, Args)whereArgsis anything that implementsSerialize
let select_query = "SELECT * FROM cars".into_query();
let insert_query = (
"INSERT INTO cars DOCUMENTS (:doc)",
json!({"doc": {"foo": "bar"}}),
).into_query();§The Args type
This type is generic over its arguments, with the requirement that the arguments must:
- implement
Serialize - serialize to a map-like type (e.g.
serde_json::json!({"some": "object"})orHashMap, not aString)
If the arguments are mutated using interior mutability, the result is not specified and may
cause logic errors. Note that this is not undefined behaviour, since any errors will
be confined to this instance of Query.
When no arguments are provided, the Args type defaults to ()
Trait Implementations§
impl<Args> StructuralPartialEq for Query<Args>
Auto Trait Implementations§
impl<Args> Freeze for Query<Args>where
Args: Freeze,
impl<Args> RefUnwindSafe for Query<Args>where
Args: RefUnwindSafe,
impl<Args> Send for Query<Args>where
Args: Send,
impl<Args> Sync for Query<Args>where
Args: Sync,
impl<Args> Unpin for Query<Args>where
Args: Unpin,
impl<Args> UnwindSafe for Query<Args>where
Args: UnwindSafe,
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