diff --git a/crates/cw-storey/src/backend.rs b/crates/cw-storey/src/backend.rs index 1aa3c76..112eb06 100644 --- a/crates/cw-storey/src/backend.rs +++ b/crates/cw-storey/src/backend.rs @@ -1,5 +1,6 @@ use storey::storage::{StorageBackend, StorageBackendMut}; +/// A wrapper around a type implementing [`cosmwasm_std::Storage`] that integrates it with [`storey`]. pub struct CwStorage(pub S); impl StorageBackend for CwStorage diff --git a/crates/cw-storey/src/containers.rs b/crates/cw-storey/src/containers.rs index 59963e2..7bf97f4 100644 --- a/crates/cw-storey/src/containers.rs +++ b/crates/cw-storey/src/containers.rs @@ -1,4 +1,17 @@ +//! Storage containers for use with [*CosmWasm*] smart contracts. +//! +//! [*CosmWasm*]: https://github.com/CosmWasm/cosmwasm + +/// The [`storey::containers::Item`] type with the default encoding for [*CosmWasm*] smart +/// contracts. +/// +/// [*CosmWasm*]: https://github.com/CosmWasm/cosmwasm pub type Item = storey::containers::Item; + +/// The [`storey::containers::Column`] type with the default encoding for [*CosmWasm*] smart +/// contracts. +/// +/// [*CosmWasm*]: https://github.com/CosmWasm/cosmwasm pub type Column = storey::containers::Column; pub use storey::containers::Map; diff --git a/crates/cw-storey/src/encoding.rs b/crates/cw-storey/src/encoding.rs index 88d8c2a..24a5c05 100644 --- a/crates/cw-storey/src/encoding.rs +++ b/crates/cw-storey/src/encoding.rs @@ -1,5 +1,14 @@ use storey::encoding::{Cover, DecodableWithImpl, EncodableWithImpl, Encoding}; +/// A simple encoding that uses [*MessagePack*] to encode and decode data. +/// +/// This type implements the [`Encoding`] trait (see [`storey::encoding`]), which means it can +/// be used with some of [`storey`]'s containers to encode and decode values. +/// +/// You're unlikely to need to use this type directly for basic library usage. You might +/// need it if you're trying to use third-party containers this crate does not provide. +/// +/// [*MessagePack*]: https://msgpack.org/ pub struct CwEncoding; impl Encoding for CwEncoding { diff --git a/crates/cw-storey/src/lib.rs b/crates/cw-storey/src/lib.rs index b58563f..3dd7878 100644 --- a/crates/cw-storey/src/lib.rs +++ b/crates/cw-storey/src/lib.rs @@ -1,5 +1,18 @@ +//! An integration of [`storey`] with [*CosmWasm*]. +//! +//! This crate provides +//! - a [*CosmWasm*] storage backend for use with [`storey`] collections, +//! - a [*MessagePack*] encoding integration to be used for serializing and deserializing +//! values, and +//! - a set of container re-exports that remove the need to manually specify the +//! encoding, instead relying on the default [*MessagePack*] encoding. +//! +//! [*CosmWasm*]: https://github.com/CosmWasm/cosmwasm +//! [*MessagePack*]: https://msgpack.org/ + mod backend; pub mod containers; mod encoding; pub use backend::CwStorage; +pub use encoding::CwEncoding; diff --git a/crates/storey-encoding/src/lib.rs b/crates/storey-encoding/src/lib.rs index 915bee2..15317f5 100644 --- a/crates/storey-encoding/src/lib.rs +++ b/crates/storey-encoding/src/lib.rs @@ -1,5 +1,8 @@ pub trait Encoding { + /// The error type returned when encoding fails. type EncodeError; + + /// The error type returned when decoding fails. type DecodeError; }