Skip to content

测试async_basic.rs中报以下错误 #19

@szlele

Description

@szlele

我在测试async_basic.rs中报以下错误,连接的是华为云GaussDB,请看看怎么解决。
Compiling gaussdb-examples v0.1.1 (/home/projects/gaussdb-rust/examples)
error[E0599]: no method named clone found for struct Client in the current scope
--> examples/src/async_basic.rs:69:29
|
69 | let client = client.clone();
| ^^^^^ method not found in Client

error[E0308]: mismatched types
--> examples/src/async_basic.rs:73:37
|
73 | &[&name, &category, &price],
| ^^^^^^ expected &&str, found &{float}
|
= note: expected reference &&str
found reference &{float}

error[E0277]: the trait bound Decimal: FromSql<'_> is not satisfied
--> examples/src/async_basic.rs:104:48
|
104 | let price: rust_decimal::Decimal = row.get(3);
| ^^^ the trait FromSql<'_> is not implemented for Decimal
|
= help: the following other types implement trait FromSql<'a>:
&'a [u8]
&'a str
Box<[T]>
Box
Date
HashMap<String, Option, S>
IpAddr
Option
and 14 others
note: required by a bound in tokio_gaussdb::Row::get
--> /home/projects/gaussdb-rust/tokio-gaussdb/src/row.rs:149:12
|
146 | pub fn get<'a, I, T>(&'a self, idx: I) -> T
| --- required by a bound in this associated function
...
149 | T: FromSql<'a>,
| ^^^^^^^^^^^ required by this bound in Row::get

error[E0277]: the trait bound Decimal: FromSql<'_> is not satisfied
--> examples/src/async_basic.rs:122:48
|
122 | let price: rust_decimal::Decimal = row.get(1);
| ^^^ the trait FromSql<'_> is not implemented for Decimal
|
= help: the following other types implement trait FromSql<'a>:
&'a [u8]
&'a str
Box<[T]>
Box
Date
HashMap<String, Option, S>
IpAddr
Option
and 14 others
note: required by a bound in tokio_gaussdb::Row::get
--> /home/projects/gaussdb-rust/tokio-gaussdb/src/row.rs:149:12
|
146 | pub fn get<'a, I, T>(&'a self, idx: I) -> T
| --- required by a bound in this associated function
...
149 | T: FromSql<'a>,
| ^^^^^^^^^^^ required by this bound in Row::get

error[E0277]: PhantomPinned cannot be unpinned
--> examples/src/async_basic.rs:157:34
|
157 | while let Some(row) = stream.try_next().await? {
| ^^^^^^^^ unsatisfied trait bound
|
= help: within tokio_gaussdb::query::_::__Origin<'_>, the trait Unpin is not implemented for PhantomPinned
= note: consider using the pin! macro
consider using Box::pin if you need to access the pinned value outside of the current scope
note: required because it appears within the type tokio_gaussdb::query::_::__Origin<'_>
--> /home/projects/gaussdb-rust/tokio-gaussdb/src/query.rs:286:1
|
286 | / pin_project! {
287 | | /// A stream of table rows.
288 | | pub struct RowStream {
289 | | statement: Statement,
... |
295 | | }
| |^
= note: required for RowStream to implement Unpin
note: required by a bound in try_next
--> /root/.cargo/registry/src/rsproxy.cn-e3de039b2554c837/futures-util-0.3.31/src/stream/try_stream/mod.rs:406:15
|
404 | fn try_next(&mut self) -> TryNext<'
, Self>
| -------- required by a bound in this associated function
405 | where
406 | Self: Unpin,
| ^^^^^ required by this bound in TryStreamExt::try_next
= note: this error originates in the macro $crate::__pin_project_make_unpin_impl which comes from the expansion of the macro pin_project (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: PhantomPinned cannot be unpinned
--> examples/src/async_basic.rs:157:45
|
157 | while let Some(row) = stream.try_next().await? {
| ^^^^^ unsatisfied trait bound
|
= help: within tokio_gaussdb::query::_::__Origin<'_>, the trait Unpin is not implemented for PhantomPinned
= note: consider using the pin! macro
consider using Box::pin if you need to access the pinned value outside of the current scope
note: required because it appears within the type tokio_gaussdb::query::_::__Origin<'_>
--> /home/projects/gaussdb-rust/tokio-gaussdb/src/query.rs:286:1
|
286 | / pin_project! {
287 | | /// A stream of table rows.
288 | | pub struct RowStream {
289 | | statement: Statement,
... |
295 | | }
| |_^
= note: required for RowStream to implement Unpin
= note: required for TryNext<'_, RowStream> to implement futures_util::Future
= note: required for TryNext<'_, RowStream> to implement std::future::IntoFuture
= note: this error originates in the macro $crate::__pin_project_make_unpin_impl which comes from the expansion of the macro pin_project (in Nightly builds, run with -Z macro-backtrace for more info)
help: remove the .await
|
157 - while let Some(row) = stream.try_next().await? {
157 + while let Some(row) = stream.try_next()? {
|

error[E0277]: the trait bound Decimal: FromSql<'_> is not satisfied
--> examples/src/async_basic.rs:159:48
|
159 | let price: rust_decimal::Decimal = row.get(1);
| ^^^ the trait FromSql<'_> is not implemented for Decimal
|
= help: the following other types implement trait FromSql<'a>:
&'a [u8]
&'a str
Box<[T]>
Box
Date
HashMap<String, Option, S>
IpAddr
Option
and 14 others
note: required by a bound in tokio_gaussdb::Row::get
--> /home/projects/gaussdb-rust/tokio-gaussdb/src/row.rs:149:12
|
146 | pub fn get<'a, I, T>(&'a self, idx: I) -> T
| --- required by a bound in this associated function
...
149 | T: FromSql<'a>,
| ^^^^^^^^^^^ required by this bound in Row::get

error[E0277]: the trait bound Decimal: FromSql<'_> is not satisfied
--> examples/src/async_basic.rs:176:48
|
176 | let price: rust_decimal::Decimal = row.get(1);
| ^^^ the trait FromSql<'_> is not implemented for Decimal
|
= help: the following other types implement trait FromSql<'a>:
&'a [u8]
&'a str
Box<[T]>
Box
Date
HashMap<String, Option, S>
IpAddr
Option
and 14 others
note: required by a bound in tokio_gaussdb::Row::get
--> /home/projects/gaussdb-rust/tokio-gaussdb/src/row.rs:149:12
|
146 | pub fn get<'a, I, T>(&'a self, idx: I) -> T
| --- required by a bound in this associated function
...
149 | T: FromSql<'a>,
| ^^^^^^^^^^^ required by this bound in Row::get

error[E0277]: the trait bound Decimal: FromSql<'_> is not satisfied
--> examples/src/async_basic.rs:210:58
|
210 | let avg_price: Option<rust_decimal::Decimal> = stats.get(2);
| ^^^ the trait FromSql<'_> is not implemented for Decimal
|
= help: the following other types implement trait FromSql<'a>:
&'a [u8]
&'a str
Box<[T]>
Box
Date
HashMap<String, Option, S>
IpAddr
Option
and 14 others
= note: required for Option<Decimal> to implement FromSql<'_>
note: required by a bound in tokio_gaussdb::Row::get
--> /home/projects/gaussdb-rust/tokio-gaussdb/src/row.rs:149:12
|
146 | pub fn get<'a, I, T>(&'a self, idx: I) -> T
| --- required by a bound in this associated function
...
149 | T: FromSql<'a>,
| ^^^^^^^^^^^ required by this bound in Row::get

error[E0277]: the trait bound Decimal: FromSql<'_> is not satisfied
--> examples/src/async_basic.rs:211:50
|
211 | let max_price: rust_decimal::Decimal = stats.get(3);
| ^^^ the trait FromSql<'_> is not implemented for Decimal
|
= help: the following other types implement trait FromSql<'a>:
&'a [u8]
&'a str
Box<[T]>
Box
Date
HashMap<String, Option, S>
IpAddr
Option
and 14 others
note: required by a bound in tokio_gaussdb::Row::get
--> /home/projects/gaussdb-rust/tokio-gaussdb/src/row.rs:149:12
|
146 | pub fn get<'a, I, T>(&'a self, idx: I) -> T
| --- required by a bound in this associated function
...
149 | T: FromSql<'a>,
| ^^^^^^^^^^^ required by this bound in Row::get

error[E0277]: the trait bound Decimal: FromSql<'_> is not satisfied
--> examples/src/async_basic.rs:212:50
|
212 | let min_price: rust_decimal::Decimal = stats.get(4);
| ^^^ the trait FromSql<'_> is not implemented for Decimal
|
= help: the following other types implement trait FromSql<'a>:
&'a [u8]
&'a str
Box<[T]>
Box
Date
HashMap<String, Option, S>
IpAddr
Option
and 14 others
note: required by a bound in tokio_gaussdb::Row::get
--> /home/projects/gaussdb-rust/tokio-gaussdb/src/row.rs:149:12
|
146 | pub fn get<'a, I, T>(&'a self, idx: I) -> T
| --- required by a bound in this associated function
...
149 | T: FromSql<'a>,
| ^^^^^^^^^^^ required by this bound in Row::get

Some errors have detailed explanations: E0277, E0308, E0599.
For more information about an error, try rustc --explain E0277.
error: could not compile gaussdb-examples (bin "async_basic") due to 11 previous errors

而且我还发现DECIMAL 或 NUMERIC 类型在 tokio-gaussdb 中没有直接的 f64 映射支持。

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions