Crate wasmcloud_actor_blobstore[−][src]
Expand description
wasmCloud Blob Store Actor Interface
This crate provides wasmCloud actors with an interface to the blobstore capability provider.
Actors using this interface must have the claim wasmcloud:blobstore
in order to have
permission to communicate with the store.
This generic protocol can be used to support capability providers like local blob storage, Amazon S3, Azure blob storage, Google blob storage, and more.
Example:
extern crate wapc_guest as guest; use guest::prelude::*; use wasmcloud_actor_blobstore as blobstore; use wasmcloud_actor_http_server as http; use wasmcloud_actor_core::serialize; use wasmcloud_actor_core as actor; use blobstore::*; use serde_json::json; use log::{error, info}; #[actor::init] fn init() { http::Handlers::register_handle_request(download_poem); blobstore::Handlers::register_receive_chunk(handle_chunk); } /// Start the download of a blob (poem). Chunks will be streamed after download begins fn download_poem(req: http::Request) -> HandlerResult<http::Response> { // replace `start_download` with `blobstore::default().start_download` match start_download(req.path, "poems".to_string(), 4096, None) { Ok(_) => Ok(http::Response::ok()), Err(_) => Err("Failed to initiate download of chunk".into()) } } /// Handle the incoming chunk as a poem "verse" and log the result /// Note that these chunks can be received out of order, so the poem /// in this case might be displayed in a different order and could look /// funny if the verse continues across a chunk boundary fn handle_chunk(chunk: FileChunk) -> HandlerResult<()> { let verse = String::from_utf8(chunk.chunk_bytes)?; info!("Poem {} part {}:\n{}", chunk.id, chunk.sequence_no, verse); Ok(()) }
Structs
Blob | A blob is a representation of an object in a blobstore, similar to a file in a file system. |
BlobList | A wrapper object around a list of blobs. |
BlobstoreResult | Used to return success and error information for common blobstore operations |
Container | A container is a logical grouping of blobs, similar to a directory in a file system. |
ContainerList | A wrapper object around a list of containers. |
CreateContainerArgs | |
FileChunk | Represents a single chunk that may comprise part of a file or an entire file. The fields for sequence number, total bytes and chunk bytes should be used to determine the chunk order, as well as the optional context field. |
GetObjectInfoArgs | |
Handlers | |
Host | |
ListObjectsArgs | |
ReceiveChunkArgs | |
RemoveContainerArgs | |
RemoveObjectArgs | |
StartDownloadArgs | |
StartUploadArgs | |
Transfer | |
UploadChunkArgs |
Constants
OP_CREATE_CONTAINER | Guest sends a Container to the capability provider, receives a Container back |
OP_GET_OBJECT_INFO | Query information on a single blob. Guest sends an incomplete blob struct and gets a complete one in return |
OP_LIST_OBJECTS | Guest sends a Container to the capability provider, receives a BlobList back |
OP_RECEIVE_CHUNK | Guest will receive a FileChunk for each piece of a file requested to download |
OP_REMOVE_CONTAINER | Guest sends a Container to the capability provider, lack of error indicates success |
OP_REMOVE_OBJECT | Guest sends a Blob to the capability provider, lack of error indicates success |
OP_START_DOWNLOAD | Guest sends a StreamRequest to the capability provider, immediate termination w/success. Guest will then start receiving OP_RECEIVE_CHUNK operations from the provider as chunks are streamed to the guest |
OP_START_UPLOAD | Guest sends a metadata-carrying FileChunk to initiate an upload, lack of error is success |
OP_UPLOAD_CHUNK | Guest sends a FileChunk to capability provider for storing as part of a Blob, lack of error indicates success |
Functions
default | Creates the default host binding |
deserialize | The standard function for de-serializing codec structs from a format suitable for message exchange between actor and host. Use of any other function to deserialize could result in breaking incompatibilities. |
host | Creates a named host binding |
serialize | The standard function for serializing codec structs into a format that can be used for message exchange between actor and host. Use of any other function to serialize could result in breaking incompatibilities. |