I’m getting the following error during cargo build. And I’m not sure how to resolve this.
error: not &self method
--> src/new_service.rs:20:18
|
20 | pub async fn new() -> Self {
| ^^^
relevant part of src/new_service.rs:
pub struct Service {
start: Event,
collections: Vec<Collection>,
clients: Vec<Client>,
}
#[dbus_interface(name ="org.freedesktop.Secret.Service")]
impl Service {
pub async fn new() -> Self {
Service {
start: event_listener::Event::new(),
collections: Vec::new(),
clients: Vec::new(),
}
}
.....
>Solution :
You can have multiple impl blocks for the same type, and that looks needed here since new wouldn’t be a callable DBus method. Try structuring your code like so:
pub struct Service {
start: Event,
collections: Vec<Collection>,
clients: Vec<Client>,
}
impl Service {
pub fn new() -> Self {
Service {
start: event_listener::Event::new(),
collections: Vec::new(),
clients: Vec::new(),
}
}
}
#[dbus_interface(name ="org.freedesktop.Secret.Service")]
impl Service {
.....
}