diff --git a/CHANGELOG.md b/CHANGELOG.md index efe3fa7..6487aab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## 0.2.0 - 2023-04-08 ### Added diff --git a/Cargo.toml b/Cargo.toml index 54df5f7..1c640c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shortguid" -version = "0.2.0-unstable" +version = "0.2.0" edition = "2021" license = "EUPL-1.2" description = "Short URL-safe Base64 encoded UUIDs" diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index 22cd5eb..ab01974 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -89,7 +89,7 @@ dependencies = [ [[package]] name = "shortguid" -version = "0.2.0-unstable" +version = "0.2.0" dependencies = [ "arbitrary", "base64", diff --git a/src/lib.rs b/src/lib.rs index fd9053a..7a1c35c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,12 @@ //! Provides short, URL-safe UUID representations. +//! +//! ``` +//! # use shortguid::ShortGuid; +//! let short_guid_a = ShortGuid::try_parse("c9a646d3-9c61-4cb7-bfcd-ee2522c8f633").unwrap(); +//! let short_guid_b = ShortGuid::try_parse("yaZG05xhTLe_ze4lIsj2Mw").unwrap(); +//! assert_eq!(short_guid_a, "yaZG05xhTLe_ze4lIsj2Mw"); +//! assert_eq!(short_guid_a, short_guid_b); +//! ``` use base64::{DecodeError, Engine}; use std::borrow::Borrow; @@ -323,9 +331,14 @@ impl AsRef<[u8]> for ShortGuid { } } +/// A parsing error. #[derive(Eq, PartialEq)] pub enum ParseError { + /// The provided input had an invalid length. + /// The contained value is the actual size. InvalidLength(usize), + /// The provided input had an invalid format. + /// The contained value is the underlying decoding error. InvalidFormat(DecodeError), }