As we can see here, ic-cdk
re-exports some library functions, mainly candid
and serde
.
I think if those crates are necessary for using ic-cdk
, it would be much clearer to let canister developers import candid
or serde
directly by themselves.
- When you want to use
ic-cdk
, you still have to importcandid
andserde
in most cases. - And it’s annoying the compiler throws errors when you want to use only
candid
(I’m not sure if this is a bug of the rust compiler):
[dependencies]
of ic00_types
should only need candid
, and ic-cdk
is not imported in reality, but there are a lot of strange errors:
--> /Users/x/.cargo/git/checkouts/ic-55f61c774f0feae0/551408d/rs/types/ic00_types/src/lib.rs:997:10
|
997 | #[derive(CandidType, Deserialize)]
| ^^^^^^^^^^ not found in `ic_cdk::export::candid::types`
|
= note: this error originates in the derive macro `CandidType` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing one of these items
|
5 | use candid::types::TypeId;
|
5 | use core::any::TypeId;
|
5 | use std::any::TypeId;
|
help: if you import `TypeId`, refer to it directly
|
997 - #[derive(CandidType, Deserialize)]
997 + #[derive(CandidType, Deserialize)]
|
error[E0433]: failed to resolve: could not find `ic_cdk` in the list of imported crates
Since the open source of the ic repo in May last year, when importing the library of the ic repo as a dependency into other projects, I have often received this problem.