pub struct ObjectStore { /* private fields */ }
Available on crate feature unstable only.
Expand description

A blob store capable of storing large objects efficiently in streams.

Implementations

Retrieve the current information for the object.

Examples
let bucket = context.create_object_store(&Config {
  bucket: "info".to_string(),
  ..Default::default()
})?;

let bytes = vec![0];
let info = bucket.put("foo", &mut bytes.as_slice())?;
assert_eq!(info.name, "foo");
assert_eq!(info.size, bytes.len());

Seals the object store from further modifications.

Put will place the contents from the given reader into this object-store.

Example
let bucket = context.create_object_store(&Config {
  bucket: "put".to_string(),
  ..Default::default()
})?;

let bytes = vec![0, 1, 2, 3, 4];
let info = bucket.put("foo", &mut bytes.as_slice())?;
assert_eq!(bucket.info("foo").unwrap(), info);

Get an existing object by name.

Example
use std::io::Read;
let bucket = context.create_object_store(&Config {
  bucket: "get".to_string(),
  ..Default::default()
})?;

let bytes = vec![0, 1, 2, 3, 4];
let info = bucket.put("foo", &mut bytes.as_slice())?;

let mut result = Vec::new();
bucket.get("foo").unwrap().read_to_end(&mut result)?;

Places a delete marker and purges the data stream associated with the key.

Example
use std::io::Read;
let bucket = context.create_object_store(&Config {
  bucket: "delete".to_string(),
  ..Default::default()
})?;

let bytes = vec![0, 1, 2, 3, 4];
bucket.put("foo", &mut bytes.as_slice())?;

bucket.delete("foo")?;

let info = bucket.info("foo")?;
assert!(info.deleted);
assert_eq!(info.size, 0);
assert_eq!(info.chunks, 0);

Watch for changes in the underlying store and receive meta information updates.

Example
use std::io::Read;
let bucket = context.create_object_store(&Config {
  bucket: "watch".to_string(),
  ..Default::default()
})?;

let mut watch = bucket.watch()?;

let bytes = vec![0, 1, 2, 3, 4];
bucket.put("foo", &mut bytes.as_slice())?;

let info = watch.next().unwrap();
assert_eq!(info.name, "foo");
assert_eq!(info.size, bytes.len());

let bytes = vec![0];
bucket.put("bar", &mut bytes.as_slice())?;

let info = watch.next().unwrap();
assert_eq!(info.name, "bar");
assert_eq!(info.size, bytes.len());

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.