pub struct ObjectStore { /* private fields */ }
Expand description
A blob store capable of storing large objects efficiently in streams.
Implementations§
Source§impl ObjectStore
impl ObjectStore
Sourcepub async fn get<T: AsRef<str>>(
&self,
object_name: T,
) -> Result<Object<'_>, Error>
pub async fn get<T: AsRef<str>>( &self, object_name: T, ) -> Result<Object<'_>, Error>
Gets an Object from the ObjectStore.
Object implements tokio::io::AsyncRead that allows to read the data from Object Store.
§Examples
use tokio::io::AsyncReadExt;
let client = async_nats::connect("demo.nats.io").await?;
let jetstream = async_nats::jetstream::new(client);
let bucket = jetstream.get_object_store("store").await?;
let mut object = bucket.get("FOO").await?;
// Object implements `tokio::io::AsyncRead`.
let mut bytes = vec![];
object.read_to_end(&mut bytes).await?;
Sourcepub async fn delete<T: AsRef<str>>(&self, object_name: T) -> Result<(), Error>
pub async fn delete<T: AsRef<str>>(&self, object_name: T) -> Result<(), Error>
Gets an Object from the ObjectStore.
Object implements tokio::io::AsyncRead that allows to read the data from Object Store.
§Examples
let client = async_nats::connect("demo.nats.io").await?;
let jetstream = async_nats::jetstream::new(client);
let bucket = jetstream.get_object_store("store").await?;
bucket.delete("FOO").await?;
Sourcepub async fn info<T: AsRef<str>>(
&self,
object_name: T,
) -> Result<ObjectInfo, Error>
pub async fn info<T: AsRef<str>>( &self, object_name: T, ) -> Result<ObjectInfo, Error>
Retrieves Object ObjectInfo.
§Examples
let client = async_nats::connect("demo.nats.io").await?;
let jetstream = async_nats::jetstream::new(client);
let bucket = jetstream.get_object_store("store").await?;
let info = bucket.info("FOO").await?;
Sourcepub async fn put<T>(
&self,
meta: T,
data: &mut (impl AsyncRead + Unpin),
) -> Result<ObjectInfo, Error>where
ObjectMeta: From<T>,
pub async fn put<T>(
&self,
meta: T,
data: &mut (impl AsyncRead + Unpin),
) -> Result<ObjectInfo, Error>where
ObjectMeta: From<T>,
Puts an Object into the ObjectStore.
This method implements tokio::io::AsyncRead
.
§Examples
let client = async_nats::connect("demo.nats.io").await?;
let jetstream = async_nats::jetstream::new(client);
let bucket = jetstream.get_object_store("store").await?;
let mut file = tokio::fs::File::open("foo.txt").await?;
bucket.put("file", &mut file).await.unwrap();
Sourcepub async fn watch(&self) -> Result<Watch<'_>, Error>
pub async fn watch(&self) -> Result<Watch<'_>, Error>
Creates a Watch stream over changes in the ObjectStore.
§Examples
use futures::StreamExt;
let client = async_nats::connect("demo.nats.io").await?;
let jetstream = async_nats::jetstream::new(client);
let bucket = jetstream.get_object_store("store").await?;
let mut watcher = bucket.watch().await.unwrap();
while let Some(object) = watcher.next().await {
println!("detected changes in {:?}", object?);
}
Sourcepub async fn list(&self) -> Result<List<'_>, Error>
pub async fn list(&self) -> Result<List<'_>, Error>
Returns a List stream with all not deleted Objects in the ObjectStore.
§Examples
use futures::StreamExt;
let client = async_nats::connect("demo.nats.io").await?;
let jetstream = async_nats::jetstream::new(client);
let bucket = jetstream.get_object_store("store").await?;
let mut list = bucket.list().await.unwrap();
while let Some(object) = list.next().await {
println!("object {:?}", object?);
}
Sourcepub async fn seal(&mut self) -> Result<(), Error>
pub async fn seal(&mut self) -> Result<(), Error>
Seals a ObjectStore, preventing any further changes to it or its Objects.
§Examples
use futures::StreamExt;
let client = async_nats::connect("demo.nats.io").await?;
let jetstream = async_nats::jetstream::new(client);
let mut bucket = jetstream.get_object_store("store").await?;
bucket.seal().await.unwrap();
Trait Implementations§
Source§impl Clone for ObjectStore
impl Clone for ObjectStore
Source§fn clone(&self) -> ObjectStore
fn clone(&self) -> ObjectStore
Returns a copy 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 Freeze for ObjectStore
impl !RefUnwindSafe for ObjectStore
impl Send for ObjectStore
impl Sync for ObjectStore
impl Unpin for ObjectStore
impl !UnwindSafe for ObjectStore
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