| 1 | 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#; |
| 2 | use craterust-analyzer cargo sqlx-core 0.8.3 crate/::decoderust-analyzer cargo sqlx-core 0.8.3 decode/::Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#; |
| 3 | use craterust-analyzer cargo sqlx-core 0.8.3 crate/::errorrust-analyzer cargo sqlx-core 0.8.3 error/::{mismatched_typesrust-analyzer cargo sqlx-core 0.8.3 error/mismatched_types()., Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#}; |
| 4 | use craterust-analyzer cargo sqlx-core 0.8.3 crate/::type_inforust-analyzer cargo sqlx-core 0.8.3 type_info/::TypeInforust-analyzer cargo sqlx-core 0.8.3 type_info/TypeInfo#; |
| 5 | 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#; |
| 6 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#; |
| 7 | |
| 8 | /// An owned value from the database. |
| 9 | pub trait Valuerust-analyzer cargo sqlx-core 0.8.3 value/Value# { |
| 10 | type Databaserust-analyzer cargo sqlx-core 0.8.3 value/Value#Database#: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#<Valuerust-analyzer cargo sqlx-core 0.8.3 database/Database#Value# = Self>; |
| 11 | |
| 12 | /// Get this value as a reference. |
| 13 | fn as_refrust-analyzer cargo sqlx-core 0.8.3 value/Value#as_ref().(&self) -> <Self::Databaserust-analyzer cargo sqlx-core 0.8.3 value/Value#Database# as Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>::ValueRefrust-analyzer cargo sqlx-core 0.8.3 database/Database#ValueRef#<'_>; |
| 14 | |
| 15 | /// Get the type information for this value. |
| 16 | fn type_inforust-analyzer cargo sqlx-core 0.8.3 value/Value#type_info().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, <Self::Databaserust-analyzer cargo sqlx-core 0.8.3 value/Value#Database# as Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>::TypeInforust-analyzer cargo sqlx-core 0.8.3 database/Database#TypeInfo#>; |
| 17 | |
| 18 | /// Returns `true` if the SQL value is `NULL`. |
| 19 | fn is_nullrust-analyzer cargo sqlx-core 0.8.3 value/Value#is_null().(&self) -> bool; |
| 20 | |
| 21 | /// Decode this single value into the requested type. |
| 22 | /// |
| 23 | /// # Panics |
| 24 | /// |
| 25 | /// Panics if the value cannot be decoded into the requested type. |
| 26 | /// See [`try_decode`](Self::try_decode) for a non-panicking version. |
| 27 | /// |
| 28 | #[inline] |
| 29 | fn decoderust-analyzer cargo sqlx-core 0.8.3 value/Value#decode().<'r, T>(&'r self) -> T |
| 30 | where |
| 31 | T: Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, Self::Databaserust-analyzer cargo sqlx-core 0.8.3 value/Value#Database#> + Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<Self::Databaserust-analyzer cargo sqlx-core 0.8.3 value/Value#Database#>, |
| 32 | { |
| 33 | self.try_decoderust-analyzer cargo sqlx-core 0.8.3 value/Value#try_decode().::<T>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 34 | } |
| 35 | |
| 36 | /// Decode this single value into the requested type. |
| 37 | /// |
| 38 | /// Unlike [`decode`](Self::decode), this method does not check that the type of this |
| 39 | /// value is compatible with the Rust type and blindly tries to decode the value. |
| 40 | /// |
| 41 | /// # Panics |
| 42 | /// |
| 43 | /// Panics if the value cannot be decoded into the requested type. |
| 44 | /// See [`try_decode_unchecked`](Self::try_decode_unchecked) for a non-panicking version. |
| 45 | /// |
| 46 | #[inline] |
| 47 | fn decode_uncheckedrust-analyzer cargo sqlx-core 0.8.3 value/Value#decode_unchecked().<'r, T>(&'r self) -> T |
| 48 | where |
| 49 | T: Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, Self::Databaserust-analyzer cargo sqlx-core 0.8.3 value/Value#Database#>, |
| 50 | { |
| 51 | self.try_decode_uncheckedrust-analyzer cargo sqlx-core 0.8.3 value/Value#try_decode_unchecked().::<T>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 52 | } |
| 53 | |
| 54 | /// Decode this single value into the requested type. |
| 55 | /// |
| 56 | /// # Errors |
| 57 | /// |
| 58 | /// * [`Decode`] if the value could not be decoded into the requested type. |
| 59 | /// |
| 60 | /// [`Decode`]: Error::Decode |
| 61 | /// |
| 62 | #[inline] |
| 63 | fn try_decoderust-analyzer cargo sqlx-core 0.8.3 value/Value#try_decode().<'r, T>(&'r self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> |
| 64 | where |
| 65 | T: Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, Self::Databaserust-analyzer cargo sqlx-core 0.8.3 value/Value#Database#> + Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<Self::Databaserust-analyzer cargo sqlx-core 0.8.3 value/Value#Database#>, |
| 66 | { |
| 67 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.is_nullrust-analyzer cargo sqlx-core 0.8.3 value/Value#is_null().() { |
| 68 | let ty = self.type_inforust-analyzer cargo sqlx-core 0.8.3 value/Value#type_info().(); |
| 69 | |
| 70 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().ty.is_nullrust-analyzer cargo sqlx-core 0.8.3 type_info/TypeInfo#is_null().() && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().T::compatiblerust-analyzer cargo sqlx-core 0.8.3 types/Type#compatible().(&ty) { |
| 71 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::Decoderust-analyzer cargo sqlx-core 0.8.3 error/Error#Decode#(mismatched_typesrust-analyzer cargo sqlx-core 0.8.3 error/mismatched_types().::<Self::Databaserust-analyzer cargo sqlx-core 0.8.3 value/Value#Database#, T>(&ty))); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | self.try_decode_uncheckedrust-analyzer cargo sqlx-core 0.8.3 value/Value#try_decode_unchecked().() |
| 76 | } |
| 77 | |
| 78 | /// Decode this single value into the requested type. |
| 79 | /// |
| 80 | /// Unlike [`try_decode`](Self::try_decode), this method does not check that the type of this |
| 81 | /// value is compatible with the Rust type and blindly tries to decode the value. |
| 82 | /// |
| 83 | /// # Errors |
| 84 | /// |
| 85 | /// * [`Decode`] if the value could not be decoded into the requested type. |
| 86 | /// |
| 87 | /// [`Decode`]: Error::Decode |
| 88 | /// |
| 89 | #[inline] |
| 90 | fn try_decode_uncheckedrust-analyzer cargo sqlx-core 0.8.3 value/Value#try_decode_unchecked().<'r, T>(&'r self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> |
| 91 | where |
| 92 | T: Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, Self::Databaserust-analyzer cargo sqlx-core 0.8.3 value/Value#Database#>, |
| 93 | { |
| 94 | T::decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#decode().(self.as_refrust-analyzer cargo sqlx-core 0.8.3 value/Value#as_ref().()).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::Decoderust-analyzer cargo sqlx-core 0.8.3 error/Error#Decode#) |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /// A reference to a single value from the database. |
| 99 | pub trait ValueRefrust-analyzer cargo sqlx-core 0.8.3 value/ValueRef#<'r>: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# { |
| 100 | type Databaserust-analyzer cargo sqlx-core 0.8.3 value/ValueRef#Database#: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#; |
| 101 | |
| 102 | /// Creates an owned value from this value reference. |
| 103 | /// |
| 104 | /// This is just a reference increment in PostgreSQL and MySQL and thus is `O(1)`. In SQLite, |
| 105 | /// this is a copy. |
| 106 | fn to_ownedrust-analyzer cargo sqlx-core 0.8.3 value/ValueRef#to_owned().(&self) -> <Self::Databaserust-analyzer cargo sqlx-core 0.8.3 value/ValueRef#Database# as Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>::Valuerust-analyzer cargo sqlx-core 0.8.3 database/Database#Value#; |
| 107 | |
| 108 | /// Get the type information for this value. |
| 109 | fn type_inforust-analyzer cargo sqlx-core 0.8.3 value/ValueRef#type_info().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, <Self::Databaserust-analyzer cargo sqlx-core 0.8.3 value/ValueRef#Database# as Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>::TypeInforust-analyzer cargo sqlx-core 0.8.3 database/Database#TypeInfo#>; |
| 110 | |
| 111 | /// Returns `true` if the SQL value is `NULL`. |
| 112 | fn is_nullrust-analyzer cargo sqlx-core 0.8.3 value/ValueRef#is_null().(&self) -> bool; |
| 113 | } |