mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-28 05:12:34 +00:00
basic high_level_encoder pass
This commit is contained in:
@@ -26,7 +26,7 @@ pub struct C40Encoder;
|
|||||||
|
|
||||||
impl Encoder for C40Encoder {
|
impl Encoder for C40Encoder {
|
||||||
fn encode(&self, context: &mut super::EncoderContext) -> Result<(), Exceptions> {
|
fn encode(&self, context: &mut super::EncoderContext) -> Result<(), Exceptions> {
|
||||||
self.encode_with_encode_char_fn(context, &Self::encodeChar_c40, &Self::handleEOD_c40)
|
self.encode_with_encode_char_fn(context, &Self::encodeChar_c40, &Self::handleEOD_c40, &||{self.getEncodingMode()})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn getEncodingMode(&self) -> usize {
|
fn getEncodingMode(&self) -> usize {
|
||||||
@@ -44,6 +44,7 @@ impl C40Encoder {
|
|||||||
context: &mut super::EncoderContext,
|
context: &mut super::EncoderContext,
|
||||||
encodeChar: &dyn Fn(char, &mut String) -> u32,
|
encodeChar: &dyn Fn(char, &mut String) -> u32,
|
||||||
handleEOD: &dyn Fn(&mut EncoderContext, &mut String) -> Result<(), Exceptions>,
|
handleEOD: &dyn Fn(&mut EncoderContext, &mut String) -> Result<(), Exceptions>,
|
||||||
|
getEncodingMode: &dyn Fn() -> usize,
|
||||||
) -> Result<(), Exceptions> {
|
) -> Result<(), Exceptions> {
|
||||||
//step C
|
//step C
|
||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
@@ -89,9 +90,9 @@ impl C40Encoder {
|
|||||||
let newMode = high_level_encoder::lookAheadTest(
|
let newMode = high_level_encoder::lookAheadTest(
|
||||||
context.getMessage(),
|
context.getMessage(),
|
||||||
context.pos,
|
context.pos,
|
||||||
self.getEncodingMode() as u32,
|
getEncodingMode() as u32,
|
||||||
);
|
);
|
||||||
if newMode != self.getEncodingMode() {
|
if newMode != getEncodingMode() {
|
||||||
// Return to ASCII encodation, which will actually handle latch to new mode
|
// Return to ASCII encodation, which will actually handle latch to new mode
|
||||||
context.signalEncoderChange(ASCII_ENCODATION);
|
context.signalEncoderChange(ASCII_ENCODATION);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ impl Encoder for TextEncoder {
|
|||||||
|
|
||||||
fn encode(&self, context: &mut super::EncoderContext) -> Result<(), crate::Exceptions> {
|
fn encode(&self, context: &mut super::EncoderContext) -> Result<(), crate::Exceptions> {
|
||||||
self.0
|
self.0
|
||||||
.encode_with_encode_char_fn(context, &Self::encodeChar, &C40Encoder::handleEOD_c40)
|
.encode_with_encode_char_fn(context, &Self::encodeChar, &C40Encoder::handleEOD_c40, &||{self.getEncodingMode()})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl TextEncoder {
|
impl TextEncoder {
|
||||||
|
|||||||
Reference in New Issue
Block a user