-
Notifications
You must be signed in to change notification settings - Fork 356
Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
What version of workers-rs are you using?
0.0.18
What version of wrangler are you using?
3.22.3
Describe the bug
Attempting to declare multiple #[durable_object] structs in the same module always results in a compile error.
Furthermore, there is no documentation on the macro so it's not clear how it is supposed to be used.
Steps To Reproduce
Example code:
use worker::{durable_object, Env, Request, Response};
#[durable_object]
pub struct One {
counter: u32,
}
#[durable_object]
impl DurableObject for One {
fn new(state: State, env: Env) -> Self {
Self {
counter: 0,
}
}
async fn fetch(&mut self, req: Request) -> worker::Result<Response> {
Response::ok("one")
}
}
#[durable_object]
pub struct Two {
counter: u32,
}
#[durable_object]
impl DurableObject for Two {
fn new(state: State, env: Env) -> Self {
Self {
counter: 0,
}
}
async fn fetch(&mut self, req: Request) -> worker::Result<Response> {
Response::ok("one")
}
}wrangler dev or wrangler deploy always results in a rust compiler error, because the macro apparently emits the same symbols each time it's invoked.
error[E0428]: the name `__Need_Durable_Object_Trait_Impl_With_durable_object_Attribute` is defined multiple times
--> src/durable.rs:90:1
|
72 | #[durable_object]
| ----------------- previous definition of the trait `__Need_Durable_Object_Trait_Impl_With_durable_object_Attribute` here
...
90 | #[durable_object]
| ^^^^^^^^^^^^^^^^^ `__Need_Durable_Object_Trait_Impl_With_durable_object_Attribute` redefined here
|
= note: `__Need_Durable_Object_Trait_Impl_With_durable_object_Attribute` must be defined only once in the type namespace of this module
= note: this error originates in the attribute macro `durable_object` (in Nightly builds, run with -Z macro-backtrace for more info)
nielsbergsma
Metadata
Metadata
Assignees
Labels
No labels