pub struct PaperPool { /* private fields */ }Implementations§
Source§impl PaperPool
impl PaperPool
Sourcepub fn new(
paper_addr: impl FromPaperAddr,
size: usize,
) -> Result<Self, PaperClientError>
pub fn new( paper_addr: impl FromPaperAddr, size: usize, ) -> Result<Self, PaperClientError>
Creates a new instance of a pool of clients of size size.
If a connection could not be established to any of the clients,
a PaperClientError is returned.
§Examples
use paper_client::PaperPool;
let pool = PaperPool::new("paper://127.0.0.1:3145", 4).unwrap();Sourcepub fn auth(&self, token: &str) -> Result<(), PaperClientError>
pub fn auth(&self, token: &str) -> Result<(), PaperClientError>
Attempts to authorize each client with the supplied auth token.
§Examples
use paper_client::PaperPool;
let pool = PaperPool::new("paper://127.0.0.1:3145", 4).unwrap();
if let Err(err) = pool.auth("my_token") {
println!("{err:?}");
};Sourcepub fn client(&self) -> MutexGuard<'_, PaperClient>
pub fn client(&self) -> MutexGuard<'_, PaperClient>
Obtains a guarded PaperClient. Use this client, then drop the
reference (or allow it to go out of scope). Do not hold a reference
to this client, otherwise the client will be unusable by other
threads in the future.
§Examples
use paper_client::PaperPool;
let pool = PaperPool::new("paper://127.0.0.1:3145", 4).unwrap();
match pool.client().ping() {
Ok(value) => println!("{value:?}"),
Err(err) => println!("{err:?}"),
};Trait Implementations§
Auto Trait Implementations§
impl Freeze for PaperPool
impl RefUnwindSafe for PaperPool
impl Send for PaperPool
impl Sync for PaperPool
impl Unpin for PaperPool
impl UnsafeUnpin for PaperPool
impl UnwindSafe for PaperPool
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