Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #177 from darrenldl/dev
Browse files Browse the repository at this point in the history
Code refactoring, error text spacing fix
  • Loading branch information
darrenldl committed Apr 21, 2019
2 parents 69f086a + 56b2ff6 commit fc7c11d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/cli_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ macro_rules! get_ver_and_data_par_burst_w_defaults {
$matches:expr, $json_printer:expr
) => {{
use crate::sbx_specs::string_to_ver;
use crate::encode_defaults;

match $matches.value_of("sbx_version") {
None => {
if let Some(_) = $matches.value_of("rs_data") {
Expand All @@ -257,7 +259,7 @@ macro_rules! get_ver_and_data_par_burst_w_defaults {
exit_with_msg!(usr $json_printer => "Please state the SBX version explicitly if you want to use a custom burst error resistance level");
}

(Version::V17, Some((10, 2, 10)))
(Version::V17, Some(encode_defaults::DATA_PAR_BURST))
},
Some(x) => {
let version =
Expand Down
2 changes: 1 addition & 1 deletion src/encode_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ pub fn encode_file(param: &Param) -> Result<Stats, Error> {
let max_in_file_size = ver_to_max_data_file_size(param.version);

if required_len > max_in_file_size {
return Err(Error::with_msg(&format!("Encoding range specified for \"{}\" exceeds the maximum supported file size, size to be encoded: {}, max : {}",
return Err(Error::with_msg(&format!("Encoding range specified for \"{}\" exceeds the maximum supported file size, size to be encoded : {}, max : {}",
param.in_file.as_ref().unwrap(),
required_len,
max_in_file_size)));
Expand Down
7 changes: 7 additions & 0 deletions src/encode_defaults.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pub const RS_DATA: usize = 10;

pub const RS_PARITY: usize = 2;

pub const BURST: usize = 10;

pub const DATA_PAR_BURST: (usize, usize, usize) = (RS_DATA, RS_PARITY, BURST);
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ pub mod sbx_block;
pub mod sbx_specs;
mod sbx_specs_tests;

mod encode_defaults;

mod log;

mod rs_codec;
Expand Down
4 changes: 2 additions & 2 deletions src/misc_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ macro_rules! get_RSD_from_ref_block {
let ver_usize = ver_to_usize($ref_block.get_version());
match $ref_block.get_RSD().unwrap() {
None => {
return Err(Error::with_msg(&format!("Reference block at byte {} (0x{:X}) is a metadata block but does not have RSD field(must be present to {} for version {})",
return Err(Error::with_msg(&format!("Reference block at byte {} (0x{:X}) is a metadata block but does not have RSD field (must be present to {} for version {})",
$ref_block_pos,
$ref_block_pos,
$purpose,
Expand All @@ -165,7 +165,7 @@ macro_rules! get_RSP_from_ref_block {
let ver_usize = ver_to_usize($ref_block.get_version());
match $ref_block.get_RSP().unwrap() {
None => {
return Err(Error::with_msg(&format!("Reference block at byte {} (0x{:X}) is a metadata block but does not have RSP field({} for version {})",
return Err(Error::with_msg(&format!("Reference block at byte {} (0x{:X}) is a metadata block but does not have RSP field ({} for version {})",
$ref_block_pos,
$ref_block_pos,
$purpose,
Expand Down

0 comments on commit fc7c11d

Please sign in to comment.