Debian Codegraph @

src/types/bytes.rs

raw symbols SCIP
1 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::decoderust-analyzer cargo sqlx-core 0.8.3 decode/::Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#;
2 use craterust-analyzer cargo sqlx-postgres 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#};
3 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::errorrust-analyzer cargo sqlx-postgres 0.8.3 error/::BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#;
4 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::typesrust-analyzer cargo sqlx-postgres 0.8.3 types/::Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#;
5 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#, PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#, PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#};
6
7 impl PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType# for u8 {
8 fn array_type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/impl#[u8][PgHasArrayType]array_type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# {
9 PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::BYTEArust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]BYTEA.
10 }
11 }
12
13 impl PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType# for &'_ [u8] {
14 fn array_type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/impl#[`&[u8]`][PgHasArrayType]array_type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# {
15 PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::BYTEA_ARRAYrust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]BYTEA_ARRAY.
16 }
17 }
18
19 impl PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType# for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[u8]> {
20 fn array_type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/impl#[`Box<[u8]>`][PgHasArrayType]array_type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# {
21 <[&[u8]] as Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#>>::type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/array/impl#[`[T]`][`Type<Postgres>`]type_info().()
22 }
23 }
24
25 impl PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType# for Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> {
26 fn array_type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/impl#[`Vec<u8>`][PgHasArrayType]array_type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# {
27 <[&[u8]] as Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#>>::type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/array/impl#[`[T]`][`Type<Postgres>`]type_info().()
28 }
29 }
30
31 impl<const N: usize> PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType# for [u8; N] {
32 fn array_type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/impl#[`[u8; N]`][PgHasArrayType]array_type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# {
33 <[&[u8]] as Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#>>::type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/array/impl#[`[T]`][`Type<Postgres>`]type_info().()
34 }
35 }
36
37 impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for &'_ [u8] {
38 fn encode_by_refrust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/impl#[`&[u8]`][`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#> {
39 buf.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(self);
40
41 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#)
42 }
43 }
44
45 impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[u8]> {
46 fn encode_by_refrust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/impl#[`Box<[u8]>`][`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#> {
47 <&[u8] 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().(self.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][`AsRef<T>`]as_ref().(), buf)
48 }
49 }
50
51 impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> {
52 fn encode_by_refrust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/impl#[`Vec<u8>`][`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#> {
53 <&[u8] 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().(self, buf)
54 }
55 }
56
57 impl<const N: usize> Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for [u8; N] {
58 fn encode_by_refrust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/impl#[`[u8; N]`][`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#> {
59 <&[u8] 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().(self.as_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`]as_slice().(), buf)
60 }
61 }
62
63 impl<'r> Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for &'r [u8] {
64 fn decoderust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/impl#[`&'r [u8]`][`Decode<'r, Postgres>`]decode().(value: PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#<'r>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/impl#[`&'r [u8]`][`Decode<'r, Postgres>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
65 match value.formatrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]format().() {
66 PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Binaryrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Binary# => value.as_bytesrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]as_bytes().(),
67 PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Textrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Text# => {
68 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("unsupported decode to `&[u8]` of BYTEA in a simple query; use a prepared query or decode to `Vec<u8>`".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
69 }
70 }
71 }
72 }
73
74 fn text_hex_decode_inputrust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/text_hex_decode_input().(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#<&[u8], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
75 // BYTEA is formatted as \x followed by hex characters
76 value
77 .as_bytesrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]as_bytes().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
78 .strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]strip_prefix().(b"\\x")
79 .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().("text does not start with \\x")
80 .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().)
81 }
82
83 impl Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[u8]> {
84 fn decoderust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/impl#[`Box<[u8]>`][`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/bytes/impl#[`Box<[u8]>`][`Decode<'_, Postgres>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
85 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match value.formatrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]format().() {
86 PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Binaryrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Binary# => Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/convert/impl#[`Box<[T]>`][`From<&[T]>`]from().(value.as_bytesrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]as_bytes().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
87 PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Textrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Text# => Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Box<[T], A>`][`From<Vec<T, A>>`]from().(hexrust-analyzer cargo hex 0.4.3 crate/::decoderust-analyzer cargo hex 0.4.3 decode().(text_hex_decode_inputrust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/text_hex_decode_input().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
88 })
89 }
90 }
91
92 impl Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> {
93 fn decoderust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/impl#[`Vec<u8>`][`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/bytes/impl#[`Vec<u8>`][`Decode<'_, Postgres>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
94 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match value.formatrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]format().() {
95 PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Binaryrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Binary# => value.as_bytesrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]as_bytes().()?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 slice/impl#[`[T]`][ToOwned]to_owned().(),
96 PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Textrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Text# => hexrust-analyzer cargo hex 0.4.3 crate/::decoderust-analyzer cargo hex 0.4.3 decode().(text_hex_decode_inputrust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/text_hex_decode_input().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
97 })
98 }
99 }
100
101 impl<const N: usize> Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for [u8; N] {
102 fn decoderust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/impl#[`[u8; N]`][`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/bytes/impl#[`[u8; N]`][`Decode<'_, Postgres>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
103 let mut bytes = [0u8; N];
104 match value.formatrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]format().() {
105 PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Binaryrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Binary# => {
106 bytes = value.as_bytesrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]as_bytes().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
107 }
108 PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Textrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Text# => hexrust-analyzer cargo hex 0.4.3 crate/::decode_to_slicerust-analyzer cargo hex 0.4.3 decode_to_slice().(text_hex_decode_inputrust-analyzer cargo sqlx-postgres 0.8.3 types/bytes/text_hex_decode_input().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., &mut bytes)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
109 };
110 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(bytes)
111 }
112 }