Skip to content

Commit

Permalink
Merge pull request #45 from strict-types/develop
Browse files Browse the repository at this point in the history
Fix RString strict dumb encoding. Add more ASCII types
  • Loading branch information
dr-orlovsky authored Nov 16, 2024
2 parents 9a01315 + 1ab0972 commit f7be0a7
Show file tree
Hide file tree
Showing 4 changed files with 693 additions and 40 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default-members = ["rust", "rust/derive", "rust/test_helpers"]
resolver = "2"

[workspace.package]
version = "2.8.0"
version = "2.8.1"
authors = ["Dr Maxim Orlovsky <[email protected]>"]
homepage = "https://strict-types.org"
repository = "https://github.com/strict-types/strict-encoding"
Expand Down
18 changes: 9 additions & 9 deletions rust/src/embedded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,26 +439,26 @@ impl<const MIN_LEN: usize, const MAX_LEN: usize> StrictDecode
}
}

impl<C: RestrictedCharSet, C1: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
StrictType for RString<C, C1, MIN_LEN, MAX_LEN>
impl<C1: RestrictedCharSet, C: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
StrictType for RString<C1, C, MIN_LEN, MAX_LEN>
{
const STRICT_LIB_NAME: &'static str = LIB_EMBEDDED;
fn strict_name() -> Option<TypeName> { None }
}
impl<C: RestrictedCharSet, C1: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
StrictDumb for RString<C, C1, MIN_LEN, MAX_LEN>
impl<C1: RestrictedCharSet, C: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
StrictDumb for RString<C1, C, MIN_LEN, MAX_LEN>
{
fn strict_dumb() -> Self {
Self::try_from(format!(
"{}{}",
C1::strict_dumb(),
String::from_utf8(vec![C::strict_dumb().into(); MIN_LEN]).expect("dumb")
String::from_utf8(vec![C::strict_dumb().into(); MIN_LEN - 1]).expect("dumb")
))
.expect("dumb")
}
}
impl<C: RestrictedCharSet, C1: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
StrictEncode for RString<C, C1, MIN_LEN, MAX_LEN>
impl<C1: RestrictedCharSet, C: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
StrictEncode for RString<C1, C, MIN_LEN, MAX_LEN>
{
fn strict_encode<W: TypedWrite>(&self, writer: W) -> io::Result<W> {
debug_assert_ne!(
Expand All @@ -473,8 +473,8 @@ impl<C: RestrictedCharSet, C1: RestrictedCharSet, const MIN_LEN: usize, const MA
}
}
}
impl<C: RestrictedCharSet, C1: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
StrictDecode for RString<C, C1, MIN_LEN, MAX_LEN>
impl<C1: RestrictedCharSet, C: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
StrictDecode for RString<C1, C, MIN_LEN, MAX_LEN>
{
fn strict_decode(reader: &mut impl TypedRead) -> Result<Self, DecodeError> {
let bytes = unsafe { reader.read_string::<MAX_LEN>()? };
Expand Down
Loading

0 comments on commit f7be0a7

Please sign in to comment.