Debian Codegraph @

src/types/uuid.rs

raw symbols SCIP
1 use uuidrust-analyzer cargo uuid 1.25.0 crate/::{
2 fmtrust-analyzer cargo uuid 1.25.0 fmt/::{Hyphenatedrust-analyzer cargo uuid 1.25.0 fmt/Hyphenated#, Simplerust-analyzer cargo uuid 1.25.0 fmt/Simple#},
3 Uuidrust-analyzer cargo uuid 1.25.0 Uuid#,
4 };
5
6 use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::decoderust-analyzer cargo sqlx-core 0.8.3 decode/::Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#;
7 use craterust-analyzer cargo sqlx-mysql 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#};
8 use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::errorrust-analyzer cargo sqlx-mysql 0.8.3 error/::BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#;
9 use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::iorust-analyzer cargo sqlx-mysql 0.8.3 io/::MySqlBufMutExtrust-analyzer cargo sqlx-mysql 0.8.3 io/buf_mut/MySqlBufMutExt#;
10 use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::typesrust-analyzer cargo sqlx-mysql 0.8.3 types/::Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#;
11 use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::{MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#, MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo#, MySqlValueRefrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueRef#};
12
13 impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for Uuidrust-analyzer cargo uuid 1.25.0 Uuid# {
14 fn type_inforust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Uuid][`Type<MySql>`]type_info().() -> MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo# {
15 <&[u8] as Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#>>::type_inforust-analyzer cargo sqlx-core 0.8.3 types/impl#[`&T`][`Type<DB>`]type_info().()
16 }
17
18 fn compatiblerust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Uuid][`Type<MySql>`]compatible().(ty: &MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo#) -> bool {
19 <&[u8] as Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#>>::compatiblerust-analyzer cargo sqlx-core 0.8.3 types/impl#[`&T`][`Type<DB>`]compatible().(ty)
20 }
21 }
22
23 impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for Uuidrust-analyzer cargo uuid 1.25.0 Uuid# {
24 fn encode_by_refrust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Uuid][`Encode<'_, MySql>`]encode_by_ref().(&self, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> 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#> {
25 buf.put_bytes_lenencrust-analyzer cargo sqlx-mysql 0.8.3 io/buf_mut/impl#[`Vec<u8>`][MySqlBufMutExt]put_bytes_lenenc().(self.as_bytesrust-analyzer cargo uuid 1.25.0 impl#[Uuid]as_bytes().());
26
27 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#::Norust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#No#)
28 }
29 }
30
31 impl Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'_, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for Uuidrust-analyzer cargo uuid 1.25.0 Uuid# {
32 fn decoderust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Uuid][`Decode<'_, MySql>`]decode().(value: MySqlValueRefrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueRef#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Uuid][`Decode<'_, MySql>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
33 // delegate to the &[u8] type to decode from MySQL
34 let bytes = <&[u8] as Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#>>::decoderust-analyzer cargo sqlx-mysql 0.8.3 types/bytes/impl#[`&'r [u8]`][`Decode<'r, MySql>`]decode().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
35
36 if bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().16 {
37 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
38 "Expected 16 bytes, got {}; `Uuid` uses binary format for MySQL/MariaDB. \
39 For text-formatted UUIDs, use `uuid::fmt::Hyphenated` instead of `Uuid`.",
40 bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(),
41 )
42 .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
43 }
44
45 // construct a Uuid from the returned bytes
46 Uuidrust-analyzer cargo uuid 1.25.0 Uuid#::from_slicerust-analyzer cargo uuid 1.25.0 builder/impl#[Uuid]from_slice().(bytes).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#::intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().)
47 }
48 }
49
50 impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for Hyphenatedrust-analyzer cargo uuid 1.25.0 fmt/Hyphenated# {
51 fn type_inforust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Hyphenated][`Type<MySql>`]type_info().() -> MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo# {
52 <&str as Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#>>::type_inforust-analyzer cargo sqlx-core 0.8.3 types/impl#[`&T`][`Type<DB>`]type_info().()
53 }
54
55 fn compatiblerust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Hyphenated][`Type<MySql>`]compatible().(ty: &MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo#) -> bool {
56 <&str as Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#>>::compatiblerust-analyzer cargo sqlx-core 0.8.3 types/impl#[`&T`][`Type<DB>`]compatible().(ty)
57 }
58 }
59
60 impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for Hyphenatedrust-analyzer cargo uuid 1.25.0 fmt/Hyphenated# {
61 fn encode_by_refrust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Hyphenated][`Encode<'_, MySql>`]encode_by_ref().(&self, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> 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#> {
62 buf.put_str_lenencrust-analyzer cargo sqlx-mysql 0.8.3 io/buf_mut/impl#[`Vec<u8>`][MySqlBufMutExt]put_str_lenenc().(&self.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
63
64 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#::Norust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#No#)
65 }
66 }
67
68 impl Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'_, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for Hyphenatedrust-analyzer cargo uuid 1.25.0 fmt/Hyphenated# {
69 fn decoderust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Hyphenated][`Decode<'_, MySql>`]decode().(value: MySqlValueRefrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueRef#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Hyphenated][`Decode<'_, MySql>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
70 // delegate to the &str type to decode from MySQL
71 let text = <&str as Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#>>::decoderust-analyzer cargo sqlx-mysql 0.8.3 types/str/impl#[`&'r str`][`Decode<'r, MySql>`]decode().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
72
73 // parse a UUID from the text
74 Uuidrust-analyzer cargo uuid 1.25.0 Uuid#::parse_strrust-analyzer cargo uuid 1.25.0 parser/impl#[Uuid]parse_str().(text)
75 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#::intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().)
76 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|u| u.hyphenatedrust-analyzer cargo uuid 1.25.0 fmt/impl#[Uuid]hyphenated().())
77 }
78 }
79
80 impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for Simplerust-analyzer cargo uuid 1.25.0 fmt/Simple# {
81 fn type_inforust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Simple][`Type<MySql>`]type_info().() -> MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo# {
82 <&str as Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#>>::type_inforust-analyzer cargo sqlx-core 0.8.3 types/impl#[`&T`][`Type<DB>`]type_info().()
83 }
84
85 fn compatiblerust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Simple][`Type<MySql>`]compatible().(ty: &MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo#) -> bool {
86 <&str as Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#>>::compatiblerust-analyzer cargo sqlx-core 0.8.3 types/impl#[`&T`][`Type<DB>`]compatible().(ty)
87 }
88 }
89
90 impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for Simplerust-analyzer cargo uuid 1.25.0 fmt/Simple# {
91 fn encode_by_refrust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Simple][`Encode<'_, MySql>`]encode_by_ref().(&self, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> 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#> {
92 buf.put_str_lenencrust-analyzer cargo sqlx-mysql 0.8.3 io/buf_mut/impl#[`Vec<u8>`][MySqlBufMutExt]put_str_lenenc().(&self.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
93
94 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#::Norust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#No#)
95 }
96 }
97
98 impl Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'_, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for Simplerust-analyzer cargo uuid 1.25.0 fmt/Simple# {
99 fn decoderust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Simple][`Decode<'_, MySql>`]decode().(value: MySqlValueRefrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueRef#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 types/uuid/impl#[Simple][`Decode<'_, MySql>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
100 // delegate to the &str type to decode from MySQL
101 let text = <&str as Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#>>::decoderust-analyzer cargo sqlx-mysql 0.8.3 types/str/impl#[`&'r str`][`Decode<'r, MySql>`]decode().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
102
103 // parse a UUID from the text
104 Uuidrust-analyzer cargo uuid 1.25.0 Uuid#::parse_strrust-analyzer cargo uuid 1.25.0 parser/impl#[Uuid]parse_str().(text)
105 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#::intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().)
106 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|u| u.simplerust-analyzer cargo uuid 1.25.0 fmt/impl#[Uuid]simple().())
107 }
108 }