-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
I need some help in using Ambassador to generate a delegate like my following hand crafted delegate implementation.
I see in issue 20 that what I am attempting to do may be supported. I was hoping that this pull (which issue 20 references) would allow me to do delegation like the following (similar to example in #20)
#[async_trait]
#[delegatable_trait]
pub trait ProductDaoDelegate {
async fn get_for_id(&self, id: i64) -> Result<Option<ProductModel>>;
}
// struct I want to delegate to, `MockProductDaoImpl` implements `ProductDaoDelegate` trait
#[derive(Debug)]
pub struct RwLockMockProductDaoImpl(tokio::sync::RwLock<MockProductDaoImpl>);
// hand written delegate that I want to replace with Ambassador
#[async_trait]
impl ProductDaoDelegate for RwLockMockProductDaoImpl {
async fn get_for_id(&self, id: i64) -> Result<Option<ProductModel>> {
let guard = self.0.read().await;
guard.get_for_id(id).await
}
}However I am unable to work it out.
Is someone able to given an example of delegating to a new type that wraps a tokio::sync::RwLock
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels