rename helper methods

This commit is contained in:
Vukašin Stepanović
2023-02-15 12:52:59 +00:00
parent bfcdb397ad
commit 935519ced5
133 changed files with 858 additions and 1044 deletions

View File

@@ -53,7 +53,7 @@ impl Encoder for Base256Encoder {
context.updateSymbolInfoWithLength(currentSize);
let mustPad = (context
.getSymbolInfo()
.ok_or(Exceptions::illegalStateEmpty())?
.ok_or(Exceptions::illegalState)?
.getDataCapacity()
- currentSize as u32)
> 0;
@@ -62,27 +62,26 @@ impl Encoder for Base256Encoder {
buffer.replace_range(
0..1,
&char::from_u32(dataCount as u32)
.ok_or(Exceptions::parseEmpty())?
.ok_or(Exceptions::parse)?
.to_string(),
);
} else if dataCount <= 1555 {
buffer.replace_range(
0..1,
&char::from_u32((dataCount as u32 / 250) + 249)
.ok_or(Exceptions::parseEmpty())?
.ok_or(Exceptions::parse)?
.to_string(),
);
let (ci_pos, _) = buffer
.char_indices()
.nth(1)
.ok_or(Exceptions::indexOutOfBoundsEmpty())?;
.ok_or(Exceptions::indexOutOfBounds)?;
buffer.insert(
ci_pos,
char::from_u32(dataCount as u32 % 250)
.ok_or(Exceptions::indexOutOfBoundsEmpty())?,
char::from_u32(dataCount as u32 % 250).ok_or(Exceptions::indexOutOfBounds)?,
);
} else {
return Err(Exceptions::illegalState(format!(
return Err(Exceptions::illegalStateWith(format!(
"Message length not in valid ranges: {dataCount}"
)));
}
@@ -92,13 +91,10 @@ impl Encoder for Base256Encoder {
// for (int i = 0, c = buffer.length(); i < c; i++) {
context.writeCodeword(
Self::randomize255State(
buffer
.chars()
.nth(i)
.ok_or(Exceptions::indexOutOfBoundsEmpty())?,
buffer.chars().nth(i).ok_or(Exceptions::indexOutOfBounds)?,
context.getCodewordCount() as u32 + 1,
)
.ok_or(Exceptions::parseEmpty())? as u8,
.ok_or(Exceptions::parse)? as u8,
);
}
Ok(())