diff --git a/README.md b/README.md index 8b5b03b..a364dee 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,45 @@ -# multiutil +[![](https://img.shields.io/badge/made%20by-Cryptid%20Technologies-gold.svg?style=flat-square)][CRYPTID] +[![](https://img.shields.io/badge/project-provenance-purple.svg?style=flat-square)][PROVENANCE] +[![](https://img.shields.io/badge/project-multiformats-blue.svg?style=flat-square)][MULTIFORMATS] +![](https://github.com/cryptidtech/multitrait/actions/workflows/rust.yml/badge.svg) -Helpful traits, types, and functions for constructing multicodec types. +# Multiutil + +Helpful traits, types, and functions for constructing multiformat types. + +## BaseEncoded + +The `BaseEncoded` "smart pointer" wraps any multiformat type that implements +the `EncodingInfo` trait also found in this crate. `BaseEncoding` automatically +handles base encoding the inner value using the [Multibase][MULTIBASE] text +encoding systems. + +## CodecInfo + +The `CodecInfo` trait allows a multiformat type to expose its +[Multicodec][MULTICODEC] value to code that relies on this trait. + +## Varuint + +This is an implementation of a [variable length, unsigned integer][VARUINT] +that is common to all multiformat protocols and types. + +## Varbytes + +This is the combination of a `Varuint` followed by a binary octet array of +equal length. This is a common way to encode arbitrary binary data so that any +code can skip over the data if it doesn't know how, nor want, to process it + +``` + ::= N(OCTET) + ^ ^ + / \ + count of variable number + octets of octets +``` + +[CRYPTID]: https://cryptid.tech/ +[PROVENANCE]: https://github.com/cryptidtech/provenance-specifications/ +[MULTIFORMATS]: https://github.com/multiformats/multiformats/ +[MULTIBASE]: https://github.com/multiformats/multibase +[VARUINT]: https://github.com/multiformats/unsigned-varint diff --git a/src/base_encoded.rs b/src/base_encoded.rs index c8bfcfa..aa62e18 100644 --- a/src/base_encoded.rs +++ b/src/base_encoded.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{ error::BaseEncodedError, prelude::Base, BaseEncoder, EncodingInfo, Error, DetectedEncoder, }; diff --git a/src/base_encoder.rs b/src/base_encoder.rs index eba314c..9e12d4f 100644 --- a/src/base_encoder.rs +++ b/src/base_encoder.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{ base_name, error::{BaseEncodedError, BaseEncoderError}, diff --git a/src/base_name.rs b/src/base_name.rs index a4b7cbd..0292f18 100644 --- a/src/base_name.rs +++ b/src/base_name.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::prelude::Base; /// convert a multibase Base to its string equivalent diff --git a/src/codec_info.rs b/src/codec_info.rs index 3a1b449..2bdb885 100644 --- a/src/codec_info.rs +++ b/src/codec_info.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::prelude::Codec; /// This trait exposes the codec information for multicoded types diff --git a/src/encoding_info.rs b/src/encoding_info.rs index d0b1ad6..3929b2b 100644 --- a/src/encoding_info.rs +++ b/src/encoding_info.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::prelude::Base; /// This trait exposes the preferred encoding for this multicodec type diff --git a/src/error.rs b/src/error.rs index 7adc0c1..f97f25e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 /// Errors generated by the numeric type impls #[derive(Clone, Debug, thiserror::Error)] #[non_exhaustive] diff --git a/src/lib.rs b/src/lib.rs index f5bc604..41bf299 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 //! #![warn(missing_docs)] #![deny( diff --git a/src/serde/de.rs b/src/serde/de.rs index de8f463..e5b3c82 100644 --- a/src/serde/de.rs +++ b/src/serde/de.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{BaseEncoded, BaseEncoder, EncodingInfo, Varbytes, Varuint}; use core::{fmt, marker}; use multibase::Base; diff --git a/src/serde/mod.rs b/src/serde/mod.rs index 3841275..56f1b66 100644 --- a/src/serde/mod.rs +++ b/src/serde/mod.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 //! Serde (de)serialization for ['crate::prelude::Tagged'] wrapped objects mod de; mod ser; diff --git a/src/serde/ser.rs b/src/serde/ser.rs index 23ba4fe..67e3dba 100644 --- a/src/serde/ser.rs +++ b/src/serde/ser.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{BaseEncoded, BaseEncoder, EncodingInfo, Varbytes, Varuint}; use multitrait::prelude::EncodeInto; use serde::ser; diff --git a/src/varbytes.rs b/src/varbytes.rs index e231528..9af335f 100644 --- a/src/varbytes.rs +++ b/src/varbytes.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{BaseEncoded, EncodingInfo, Error}; use core::{fmt, ops}; use multibase::Base; diff --git a/src/varuint.rs b/src/varuint.rs index 5c5b480..18ebeeb 100644 --- a/src/varuint.rs +++ b/src/varuint.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{BaseEncoded, EncodingInfo, Error}; use core::{fmt, ops}; use multibase::Base;