qp/
resource.rs

1//! A module for managed resources.
2use async_trait::async_trait;
3
4/// An interface for managing resources used by [`Pool`](crate::Pool).
5#[async_trait]
6pub trait Manage: Sync {
7    /// The type of resource managed by [`Pool`](crate::Pool).
8    type Output: Send + Sync;
9
10    /// The type of error from a resource.
11    type Error;
12
13    /// Tries to create a resource using the manager.
14    async fn try_create(&self) -> Result<Self::Output, Self::Error>;
15
16    /// Returns `true` if the given resource is valid.
17    async fn validate(&self, _resource: &Self::Output) -> bool {
18        true
19    }
20}