# How to mport custom types from candid file in rust?

**URL:** <https://forum.dfinity.org/t/how-to-mport-custom-types-from-candid-file-in-rust/14189>\
**Category:** Rust\
**Tags:** candid\
**Created:** [July 6, 2022, 11:46pm UTC](https://forum.dfinity.org/t/how-to-mport-custom-types-from-candid-file-in-rust/14189 "2022-07-06T23:46:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![h4rdcoder](https://avatars.discourse-cdn.com/v4/letter/h/58956e/32.png) [@h4rdcoder](https://forum.dfinity.org/u/h4rdcoder)\
**Post date:** [July 6, 2022, 11:46pm UTC](https://forum.dfinity.org/t/how-to-mport-custom-types-from-candid-file-in-rust/14189/1 "2022-07-06T23:46:57Z")

</div>

I know how to import function from other canisters with:

```auto
#[import(canister = "some_crate")]
struct SomeCrate

//And call a function with:
SomeCrate::function_1()

```

But if that function has a struct as parameter and that struct is defined as a type in candid:

```auto
type SomeStruct = record {
    "data": text;
};

```

I don’t know how to import the struct/type, `SomeCrate::SomeStruct` doesn’t work.

If I could import the type I could write this:

```auto
async fn exec(data: SomeCrate::SomeStruct){
  SomeCrate::function_1(data).await
}

```

But currently I’m have to re write the struct in my rust crate and that is prone to generate bugs on third party canister updates since the compiler wont detect them.  
Does the import macro only imports functions or there is a way to import types already implemented?

Thanks

---

<div class="post-metadata">

**Author:** ![famouscat8](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/famouscat8/32/4732_2.png) [@famouscat8](https://forum.dfinity.org/u/famouscat8)\
**Post date:** [June 24, 2023, 4:15pm UTC](https://forum.dfinity.org/t/how-to-mport-custom-types-from-candid-file-in-rust/14189/2 "2023-06-24T16:15:50Z")

</div>

All public interfaces defined in corresponding candid file can be accessed through the annotated struct.

```rust
#[import(canister_id = "abcde-cai", candid_path = "path/to/some_canister.did")]
struct SomeCanister;

```

[import in ic\_cdk\_macros - Rust (docs.rs)](https://docs.rs/ic-cdk-macros/latest/ic_cdk_macros/attr.import.html)
