Skip to content

Commit

Permalink
cleanup: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
hschimke committed Jul 22, 2024
1 parent de87cb5 commit f478c5d
Showing 1 changed file with 2 additions and 59 deletions.
61 changes: 2 additions & 59 deletions src/oned/one_d_code_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
* limitations under the License.
*/

use std::collections::HashMap;

use crate::{
common::{BitMatrix, Result},
BarcodeFormat, EncodeHintType, EncodeHintValue, Exceptions, Writer,
BarcodeFormat, Exceptions, Writer,
};

use once_cell::sync::Lazy;
Expand Down Expand Up @@ -141,60 +140,4 @@ pub trait OneDimensionalCodeWriter: Writer {
// This seems like a decent idea for a default for all formats.
10
}
}

struct L;
impl Writer for L {
fn encode(
&self,
contents: &str,
format: &crate::BarcodeFormat,
width: i32,
height: i32,
) -> Result<crate::common::BitMatrix> {
self.encode_with_hints(contents, format, width, height, &HashMap::new())
}

fn encode_with_hints(
&self,
contents: &str,
format: &crate::BarcodeFormat,
width: i32,
height: i32,
hints: &crate::EncodingHintDictionary,
) -> Result<crate::common::BitMatrix> {
if contents.is_empty() {
return Err(Exceptions::illegal_argument_with("Found empty contents"));
}

if width < 0 || height < 0 {
return Err(Exceptions::illegal_argument_with(format!(
"Negative size is not allowed. Input: {width}x{height}"
)));
}
if let Some(supportedFormats) = self.getSupportedWriteFormats() {
if !supportedFormats.contains(format) {
return Err(Exceptions::illegal_argument_with(format!(
"Can only encode {supportedFormats:?}, but got {format:?}"
)));
}
}

let mut sidesMargin = self.getDefaultMargin();
if let Some(EncodeHintValue::Margin(margin)) = hints.get(&EncodeHintType::MARGIN) {
sidesMargin = margin.parse::<u32>().map_err(|e| {
Exceptions::illegal_argument_with(format!("couldnt parse {margin}: {e}"))
})?;
}

let code = self.encode_oned_with_hints(contents, hints)?;

Self::renderRXingResult(&code, width, height, sidesMargin)
}
}

impl OneDimensionalCodeWriter for L {
fn encode_oned(&self, _contents: &str) -> Result<Vec<bool>> {
unimplemented!()
}
}
}

0 comments on commit f478c5d

Please sign in to comment.