# Pubsub rust example

**URL:** <https://forum.dfinity.org/t/pubsub-rust-example/5684>\
**Category:** Getting Started\
**Created:** [July 3, 2021, 2:58pm UTC](https://forum.dfinity.org/t/pubsub-rust-example/5684 "2021-07-03T14:58:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![witter](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/witter/32/4571_2.png) [@witter](https://forum.dfinity.org/u/witter)\
**Post date:** [July 3, 2021, 2:58pm UTC](https://forum.dfinity.org/t/pubsub-rust-example/5684/1 "2021-07-03T14:58:30Z")

</div>

> <https://github.com/dfinity/examples/blob/master/motoko/pub-sub/src/pub/Main.mo>

> <https://github.com/dfinity/examples/blob/master/motoko/pub-sub/src/sub/Main.mo>

Any rust example like this?

---

<div class="post-metadata">

**Author:** ![witter](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/witter/32/4571_2.png) [@witter](https://forum.dfinity.org/u/witter)\
**Post date:** [July 8, 2021, 2:03pm UTC](https://forum.dfinity.org/t/pubsub-rust-example/5684/2 "2021-07-08T14:03:33Z")

</div>

[add rust pub-sub example by weitaolee · Pull Request #109 · dfinity/examples · GitHub](https://github.com/dfinity/examples/pull/109)  
I created a rust example and submitted a PR

---

<div class="post-metadata">

**Author:** ![witter](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/witter/32/4571_2.png) [@witter](https://forum.dfinity.org/u/witter)\
**Post date:** [July 8, 2021, 2:25pm UTC](https://forum.dfinity.org/t/pubsub-rust-example/5684/3 "2021-07-08T14:25:25Z")

</div>

When writing this example, I found some problems: I tried to write exactly according to motoko’s example, but the init function motoko and rust behave inconsistently; when the init function has parameters, motoko can execute the init function after canister install, but rust you must use dfx canister install --arguments to install it. Please pay attention to this situation. If Anybody who can tell me the reasons here in depth, please give me some advice. And,thanks for the help provided by @flyq
