Debian Codegraph @

src/row.rs

raw symbols SCIP
1 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::columnrust-analyzer cargo sqlx-postgres 0.8.3 column/::ColumnIndexrust-analyzer cargo sqlx-core 0.8.3 column/ColumnIndex#;
2 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::errorrust-analyzer cargo sqlx-postgres 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#;
3 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::messagerust-analyzer cargo sqlx-postgres 0.8.3 message/::DataRowrust-analyzer cargo sqlx-postgres 0.8.3 message/data_row/DataRow#;
4 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::statementrust-analyzer cargo sqlx-postgres 0.8.3 statement/::PgStatementMetadatarust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatementMetadata#;
5 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::valuerust-analyzer cargo sqlx-postgres 0.8.3 value/::PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#;
6 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::{PgColumnrust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#, PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#};
7 pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::rowrust-analyzer cargo sqlx-core 0.8.3 row/::Rowrust-analyzer cargo sqlx-core 0.8.3 row/Row#;
8 use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::type_checkingrust-analyzer cargo sqlx-core 0.8.3 type_checking/::TypeCheckingrust-analyzer cargo sqlx-core 0.8.3 type_checking/TypeChecking#;
9 use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::valuerust-analyzer cargo sqlx-core 0.8.3 value/::ValueRefrust-analyzer cargo sqlx-core 0.8.3 value/ValueRef#;
10 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#;
11 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#;
12
13 /// Implementation of [`Row`] for PostgreSQL.
14 pub struct PgRowrust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow# {
15 pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) datarust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow#data.: DataRowrust-analyzer cargo sqlx-postgres 0.8.3 message/data_row/DataRow#,
16 pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) formatrust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow#format.: PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#,
17 pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) metadatarust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow#metadata.: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<PgStatementMetadatarust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatementMetadata#>,
18 }
19
20 impl Rowrust-analyzer cargo sqlx-core 0.8.3 row/Row# for PgRowrust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow# {
21 type Databaserust-analyzer cargo sqlx-postgres 0.8.3 row/impl#[PgRow][Row]Database# = Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#;
22
23 fn columnsrust-analyzer cargo sqlx-postgres 0.8.3 row/impl#[PgRow][Row]columns().(&self) -> &[PgColumnrust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#] {
24 &self.metadatarust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow#metadata..columnsrust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatementMetadata#columns.
25 }
26
27 fn try_get_rawrust-analyzer cargo sqlx-postgres 0.8.3 row/impl#[PgRow][Row]try_get_raw().<I>(&self, index: I) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#<'_>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>
28 where
29 I: ColumnIndexrust-analyzer cargo sqlx-core 0.8.3 column/ColumnIndex#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 row/impl#[PgRow][Row]>,
30 {
31 let index = index.indexrust-analyzer cargo sqlx-core 0.8.3 column/ColumnIndex#index().(self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
32 let column = &self.metadatarust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow#metadata..columnsrust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatementMetadata#columns.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().index]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().;
33 let value = self.datarust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow#data..getrust-analyzer cargo sqlx-postgres 0.8.3 message/data_row/impl#[DataRow]get().(index);
34
35 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef# {
36 formatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#format.: self.formatrust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow#format.,
37 rowrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#row.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&self.datarust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow#data..storagerust-analyzer cargo sqlx-postgres 0.8.3 message/data_row/DataRow#storage.),
38 type_inforust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#type_info.: column.type_inforust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#type_info..clonerust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo][Clone]clone().(),
39 valuerust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#value.,
40 })
41 }
42 }
43
44 impl ColumnIndexrust-analyzer cargo sqlx-core 0.8.3 column/ColumnIndex#<PgRowrust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow#> for &'_ str {
45 fn indexrust-analyzer cargo sqlx-postgres 0.8.3 row/impl#[`&str`][`ColumnIndex<PgRow>`]index().(&self, row: &PgRowrust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
46 row.metadatarust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow#metadata.
47 .column_namesrust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatementMetadata#column_names.
48 .getrust-analyzer cargo hashbrown 0.15.5 map/impl#[`HashMap<K, V, S, A>`]get().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self)
49 .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::ColumnNotFoundrust-analyzer cargo sqlx-core 0.8.3 error/Error#ColumnNotFound#((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))
50 .copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<&T, E>`]copied().()
51 }
52 }
53
54 impl Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for PgRowrust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow# {
55 fn fmtrust-analyzer cargo sqlx-postgres 0.8.3 row/impl#[PgRow][Debug]fmt().(&self, f: &mut 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/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> 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/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
56 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "PgRow ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
57
58 let mut debug_map = f.debug_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_map().();
59 for (index, column) in self.columnsrust-analyzer cargo sqlx-postgres 0.8.3 row/impl#[PgRow][Row]columns().().iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
60 match self.try_get_rawrust-analyzer cargo sqlx-postgres 0.8.3 row/impl#[PgRow][Row]try_get_raw().(index) {
61 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value) => {
62 debug_map.entryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugMap<'a, 'b>`]entry().(
63 &column.namerust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#name.,
64 &Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#::fmt_value_debugrust-analyzer cargo sqlx-postgres 0.8.3 type_checking/impl#[Postgres][TypeChecking]fmt_value_debug().(&<PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef# as ValueRefrust-analyzer cargo sqlx-core 0.8.3 value/ValueRef#>::to_ownedrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`][`ValueRef<'r>`]to_owned().(&value)),
65 );
66 }
67 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error) => {
68 debug_map.entryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugMap<'a, 'b>`]entry().(&column.namerust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#name., &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("decode error: {error:?}"));
69 }
70 }
71 }
72
73 debug_map.finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugMap<'a, 'b>`]finish().()
74 }
75 }