Debian Codegraph @

src/types/citext.rs

raw symbols SCIP
1 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::typesrust-analyzer cargo sqlx-postgres 0.8.3 types/::array_compatiblerust-analyzer cargo sqlx-postgres 0.8.3 types/array_compatible().;
2 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::{PgArgumentBufferrust-analyzer cargo sqlx-postgres 0.8.3 arguments/PgArgumentBuffer#, PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType#, PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#, PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#};
3 use sqlx_corerust-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#;
4 use sqlx_corerust-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#, IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#};
5 use sqlx_corerust-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 sqlx_corerust-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/;
8 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/::{Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#, Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#};
9 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#;
10 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#;
11
12 /// Case-insensitive text (`citext`) support for Postgres.
13 ///
14 /// Note that SQLx considers the `citext` type to be compatible with `String`
15 /// and its various derivatives, so direct usage of this type is generally unnecessary.
16 ///
17 /// However, it may be needed, for example, when binding a `citext[]` array,
18 /// as Postgres will generally not accept a `text[]` array (mapped from `Vec<String>`) in its place.
19 ///
20 /// See [the Postgres manual, Appendix F, Section 10][PG.F.10] for details on using `citext`.
21 ///
22 /// [PG.F.10]: https://www.postgresql.org/docs/current/citext.html
23 ///
24 /// ### Note: Extension Required
25 /// The `citext` extension is not enabled by default in Postgres. You will need to do so explicitly:
26 ///
27 /// ```ignore
28 /// CREATE EXTENSION IF NOT EXISTS "citext";
29 /// ```
30 ///
31 /// ### Note: `PartialEq` is Case-Sensitive
32 /// This type derives `PartialEq` which forwards to the implementation on `String`, which
33 /// is case-sensitive. This impl exists mainly for testing.
34 ///
35 /// To properly emulate the case-insensitivity of `citext` would require use of locale-aware
36 /// functions in `libc`, and even then would require querying the locale of the database server
37 /// and setting it locally, which is unsafe.
38 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
39 pub struct PgCiTextrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText#(pub Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#);
40
41 impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgCiTextrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText# {
42 fn type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][`Type<Postgres>`]type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# {
43 // Since `citext` is enabled by an extension, it does not have a stable OID.
44 PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::with_namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]with_name().("citext")
45 }
46
47 fn compatiblerust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][`Type<Postgres>`]compatible().(ty: &PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#) -> bool {
48 <&str as Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#>>::compatiblerust-analyzer cargo sqlx-core 0.8.3 types/impl#[`&T`][`Type<DB>`]compatible().(ty)
49 }
50 }
51
52 impl Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for PgCiTextrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText# {
53 type Targetrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][Deref]Target# = str;
54
55 fn derefrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][Deref]deref().(&self) -> &Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][Deref]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# {
56 self.0rust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText#0..as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()
57 }
58 }
59
60 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> for PgCiTextrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText# {
61 fn fromrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][`From<String>`]from().(value: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][`From<String>`] {
62 Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][`From<String>`](value)
63 }
64 }
65
66 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PgCiTextrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText#> for Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
67 fn fromrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[String][`From<PgCiText>`]from().(value: PgCiTextrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText#) -> Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[String][`From<PgCiText>`] {
68 value.0rust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText#0.
69 }
70 }
71
72 impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for PgCiTextrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText# {
73 type Errrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][FromStr]Err# = corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::Infalliblerust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Infallible#;
74
75 fn from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][FromStr], Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> {
76 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgCiTextrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText#(s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().))
77 }
78 }
79
80 impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for PgCiTextrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText# {
81 fn fmtrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][Display]fmt().(&self, f: &mut Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> 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# {
82 f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(&self.0rust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText#0.)
83 }
84 }
85
86 impl PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType# for PgCiTextrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText# {
87 fn array_type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][PgHasArrayType]array_type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# {
88 PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::with_namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]with_name().("_citext")
89 }
90
91 fn array_compatiblerust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][PgHasArrayType]array_compatible().(ty: &PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#) -> bool {
92 array_compatiblerust-analyzer cargo sqlx-postgres 0.8.3 types/array_compatible().::<&str>(ty)
93 }
94 }
95
96 impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgCiTextrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText# {
97 fn encode_by_refrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][`Encode<'_, Postgres>`]encode_by_ref().(&self, buf: &mut PgArgumentBufferrust-analyzer cargo sqlx-postgres 0.8.3 arguments/PgArgumentBuffer#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#, BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
98 <&str as Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#>>::encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#encode().(&*rust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self, buf)
99 }
100 }
101
102 impl Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgCiTextrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText# {
103 fn decoderust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][`Decode<'_, Postgres>`]decode().(value: PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/impl#[PgCiText][`Decode<'_, Postgres>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
104 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgCiTextrust-analyzer cargo sqlx-postgres 0.8.3 types/citext/PgCiText#(value.as_strrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]as_str().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()))
105 }
106 }