Debian Codegraph @

src/arguments.rs

raw symbols SCIP
1 //! Types and traits for passing arguments to SQL queries.
2
3 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::databaserust-analyzer cargo sqlx-core 0.8.3 database/::Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#;
4 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::encoderust-analyzer cargo sqlx-core 0.8.3 encode/::Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#;
5 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::errorrust-analyzer cargo sqlx-core 0.8.3 error/::BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#;
6 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::typesrust-analyzer cargo sqlx-core 0.8.3 types/::Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#;
7 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{selfrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, Writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Write#};
8
9 /// A tuple of arguments to be sent to the database.
10 // This lint is designed for general collections, but `Arguments` is not meant to be as such.
11 #[allow(clippy::len_without_is_empty)]
12 pub trait Argumentsrust-analyzer cargo sqlx-core 0.8.3 arguments/Arguments#<'q>: Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# {
13 type Databaserust-analyzer cargo sqlx-core 0.8.3 arguments/Arguments#Database#: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#;
14
15 /// Reserves the capacity for at least `additional` more values (of `size` total bytes) to
16 /// be added to the arguments without a reallocation.
17 fn reserverust-analyzer cargo sqlx-core 0.8.3 arguments/Arguments#reserve().(&mut self, additional: usize, size: usize);
18
19 /// Add the value to the end of the arguments.
20 fn addrust-analyzer cargo sqlx-core 0.8.3 arguments/Arguments#add().<T>(&mut self, value: T) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#>
21 where
22 T: 'q + Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'q, Self::Databaserust-analyzer cargo sqlx-core 0.8.3 arguments/Arguments#Database#> + Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<Self::Databaserust-analyzer cargo sqlx-core 0.8.3 arguments/Arguments#Database#>;
23
24 /// The number of arguments that were already added.
25 fn lenrust-analyzer cargo sqlx-core 0.8.3 arguments/Arguments#len().(&self) -> usize;
26
27 fn format_placeholderrust-analyzer cargo sqlx-core 0.8.3 arguments/Arguments#format_placeholder().<W: Writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Write#>(&self, writer: &mut W) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
28 writer.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Write#write_str().("?")
29 }
30 }
31
32 pub trait IntoArgumentsrust-analyzer cargo sqlx-core 0.8.3 arguments/IntoArguments#<'q, DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# {
33 fn into_argumentsrust-analyzer cargo sqlx-core 0.8.3 arguments/IntoArguments#into_arguments().(self) -> <DB as Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>::Argumentsrust-analyzer cargo sqlx-core 0.8.3 database/Database#Arguments#<'q>;
34 }
35
36 // NOTE: required due to lack of lazy normalization
37 #[macro_export]
38 macro_rules! impl_into_arguments_for_argumentsrust-analyzer cargo sqlx-core 0.8.3 arguments/impl_into_arguments_for_arguments! {
39 ($Arguments:path) => {
40 impl<'q>
41 $crate::arguments::IntoArguments<
42 'q,
43 <$Arguments as $crate::arguments::Arguments<'q>>::Database,
44 > for $Arguments
45 {
46 fn into_arguments(self) -> $Arguments {
47 self
48 }
49 }
50 };
51 }
52
53 /// used by the query macros to prevent supernumerary `.bind()` calls
54 pub struct ImmutableArgumentsrust-analyzer cargo sqlx-core 0.8.3 arguments/ImmutableArguments#<'q, DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>(pub <DB as Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>::Argumentsrust-analyzer cargo sqlx-core 0.8.3 database/Database#Arguments#<'q>);
55
56 impl<'q, DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#> IntoArgumentsrust-analyzer cargo sqlx-core 0.8.3 arguments/IntoArguments#<'q, DB> for ImmutableArgumentsrust-analyzer cargo sqlx-core 0.8.3 arguments/ImmutableArguments#<'q, DB> {
57 fn into_argumentsrust-analyzer cargo sqlx-core 0.8.3 arguments/impl#[`ImmutableArguments<'q, DB>`][`IntoArguments<'q, DB>`]into_arguments().(self) -> <DB as Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>::Argumentsrust-analyzer cargo sqlx-core 0.8.3 database/Database#Arguments#<'q> {
58 self.0rust-analyzer cargo sqlx-core 0.8.3 arguments/ImmutableArguments#0.
59 }
60 }
61
62 // TODO: Impl `IntoArguments` for &[&dyn Encode]
63 // TODO: Impl `IntoArguments` for (impl Encode, ...) x16