Skip to content

Commit

Permalink
doc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinheavey committed Jul 29, 2024
1 parent 681acf1 commit b49ed14
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/five8_const/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ While the first two functions return `Result` types,
the `_unwrap` functions are more useful for declaring constants:

```rust
const EXAMPLE: [u8; 32] = decode_32_const_unwrap("JEKNVnkbo3jma5nREBBJCDoXFVeKkD56V3xKrvRmWxFF");
const EXAMPLE: [u8; 32] = five8_const::decode_32_const_unwrap("JEKNVnkbo3jma5nREBBJCDoXFVeKkD56V3xKrvRmWxFF");
```

If you want to base58 encoding or decoding at runtime,
Expand Down
5 changes: 5 additions & 0 deletions crates/five8_const/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![doc = include_str!("../README.md")]
use five8_core::{
DecodeError, BASE58_ENCODED_32_MAX_LEN, BASE58_ENCODED_64_MAX_LEN, BASE58_INVALID_CHAR,
BASE58_INVERSE, BASE58_INVERSE_TABLE_OFFSET, BASE58_INVERSE_TABLE_SENTINEL, BINARY_SZ_32,
Expand Down Expand Up @@ -192,13 +193,15 @@ const fn decode_const_unwrap<
}
}

/// Try decode into a 32-byte array.
pub const fn decode_32_const(encoded: &str) -> Result<[u8; N_32], DecodeError> {
decode_const::<N_32, BASE58_ENCODED_32_MAX_LEN, RAW58_SZ_32, INTERMEDIATE_SZ_32, BINARY_SZ_32>(
encoded,
&DEC_TABLE_32,
)
}

/// Decode into a 32-byte array. Panic on error.
pub const fn decode_32_const_unwrap(encoded: &str) -> [u8; N_32] {
decode_const_unwrap::<
N_32,
Expand All @@ -209,13 +212,15 @@ pub const fn decode_32_const_unwrap(encoded: &str) -> [u8; N_32] {
>(encoded, &DEC_TABLE_32)
}

/// Try decode into a 64-byte array.
pub const fn decode_64_const(encoded: &str) -> Result<[u8; N_64], DecodeError> {
decode_const::<N_64, BASE58_ENCODED_64_MAX_LEN, RAW58_SZ_64, INTERMEDIATE_SZ_64, BINARY_SZ_64>(
encoded,
&DEC_TABLE_64,
)
}

/// Decode into a 64-byte array. Panic on error.
pub const fn decode_64_const_unwrap(encoded: &str) -> [u8; N_64] {
decode_const_unwrap::<
N_64,
Expand Down

0 comments on commit b49ed14

Please sign in to comment.