From 11eb0501532fb2db52029b051e730846f4b8536a Mon Sep 17 00:00:00 2001 From: Shahab Dogar Date: Wed, 10 Apr 2024 17:14:40 -0500 Subject: [PATCH] add escape hatch into async client to allow sync calls --- src/async_client.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/async_client.rs b/src/async_client.rs index 0a0c89f..0a9e0fc 100644 --- a/src/async_client.rs +++ b/src/async_client.rs @@ -22,6 +22,20 @@ impl AsyncClient { Ok(Client::connect(target)?.into()) } + /// Get a reference to the inner `Client` object. + /// This will allow you to call methods on the `Client` object synchronously. + /// + /// Example: + /// + /// ```rust + /// let client = memcache::AsyncClient::connect("memcache://localhost:12345").unwrap(); + /// let blocking_client = client.blocking(); + /// let _: Option = blocking_client.get("foo").unwrap(); + /// ``` + pub fn blocking(&self) -> &Client { + &self.inner + } + /// Set the socket read timeout for TCP connections. /// /// Example: