pub struct ResourceClient<T: ActorEntity> {
sender: Sender<ResourceRequest<T>>,
}Expand description
A type-safe client for interacting with a ResourceActor.
§ResourceClient
The ResourceClient<T> provides a type‑safe, async API for interacting with a ResourceActor<T>. It forwards CRUD + Action requests over a Tokio mpsc channel and returns results via oneshot channels. The client is cheap to clone and can be shared across tasks.
- Cloneable – holds only a sender, so cloning is inexpensive.
- Async API – all methods return
Futures that resolve toResult<…, FrameworkError>. - Generic – works with any entity that implements
ActorEntity.
Fields§
§sender: Sender<ResourceRequest<T>>Implementations§
Source§impl<T: ActorEntity> ResourceClient<T>
impl<T: ActorEntity> ResourceClient<T>
pub fn new(sender: Sender<ResourceRequest<T>>) -> Self
pub async fn create(&self, params: T::Create) -> Result<T::Id, FrameworkError>
pub async fn get(&self, id: T::Id) -> Result<Option<T>, FrameworkError>
pub async fn update( &self, id: T::Id, update: T::Update, ) -> Result<T, FrameworkError>
pub async fn delete(&self, id: T::Id) -> Result<(), FrameworkError>
pub async fn perform_action( &self, id: T::Id, action: T::Action, ) -> Result<T::ActionResult, FrameworkError>
Trait Implementations§
Source§impl<T: Clone + ActorEntity> Clone for ResourceClient<T>
impl<T: Clone + ActorEntity> Clone for ResourceClient<T>
Source§fn clone(&self) -> ResourceClient<T>
fn clone(&self) -> ResourceClient<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<T> Freeze for ResourceClient<T>
impl<T> RefUnwindSafe for ResourceClient<T>
impl<T> Send for ResourceClient<T>
impl<T> Sync for ResourceClient<T>
impl<T> Unpin for ResourceClient<T>
impl<T> UnwindSafe for ResourceClient<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more