mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
cargo fmt
This commit is contained in:
@@ -26,7 +26,7 @@ use super::{ParsedRXingResult, ParsedRXingResultType, ResultParser};
|
|||||||
*
|
*
|
||||||
* @author Sean Owen
|
* @author Sean Owen
|
||||||
*/
|
*/
|
||||||
#[derive(PartialEq, Eq,Hash,Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct AddressBookParsedRXingResult {
|
pub struct AddressBookParsedRXingResult {
|
||||||
names: Vec<String>,
|
names: Vec<String>,
|
||||||
nicknames: Vec<String>,
|
nicknames: Vec<String>,
|
||||||
|
|||||||
@@ -367,8 +367,18 @@ impl CalendarParsedRXingResult {
|
|||||||
|
|
||||||
impl PartialEq for CalendarParsedRXingResult {
|
impl PartialEq for CalendarParsedRXingResult {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.summary == other.summary && self.start == other.start && self.startAllDay == other.startAllDay && self.end == other.end && self.endAllDay == other.endAllDay && self.location == other.location && self.organizer == other.organizer && self.attendees == other.attendees && self.description == other.description && self.latitude == other.latitude && self.longitude == other.longitude
|
self.summary == other.summary
|
||||||
|
&& self.start == other.start
|
||||||
|
&& self.startAllDay == other.startAllDay
|
||||||
|
&& self.end == other.end
|
||||||
|
&& self.endAllDay == other.endAllDay
|
||||||
|
&& self.location == other.location
|
||||||
|
&& self.organizer == other.organizer
|
||||||
|
&& self.attendees == other.attendees
|
||||||
|
&& self.description == other.description
|
||||||
|
&& self.latitude == other.latitude
|
||||||
|
&& self.longitude == other.longitude
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Eq for CalendarParsedRXingResult {}
|
impl Eq for CalendarParsedRXingResult {}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ use super::{ParsedRXingResult, ParsedRXingResultType, ResultParser};
|
|||||||
*
|
*
|
||||||
* @author Sean Owen
|
* @author Sean Owen
|
||||||
*/
|
*/
|
||||||
#[derive(PartialEq, Eq,Hash,Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct EmailAddressParsedRXingResult {
|
pub struct EmailAddressParsedRXingResult {
|
||||||
tos: Vec<String>,
|
tos: Vec<String>,
|
||||||
ccs: Vec<String>,
|
ccs: Vec<String>,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ use super::{ParsedRXingResult, ParsedRXingResultType};
|
|||||||
* @author Antonio Manuel Benjumea Conde, Servinform, S.A.
|
* @author Antonio Manuel Benjumea Conde, Servinform, S.A.
|
||||||
* @author Agustín Delgado, Servinform, S.A.
|
* @author Agustín Delgado, Servinform, S.A.
|
||||||
*/
|
*/
|
||||||
#[derive(PartialEq, Eq,Debug)]
|
#[derive(PartialEq, Eq, Debug)]
|
||||||
pub struct ExpandedProductParsedRXingResult {
|
pub struct ExpandedProductParsedRXingResult {
|
||||||
rawText: String,
|
rawText: String,
|
||||||
productID: String,
|
productID: String,
|
||||||
@@ -71,7 +71,7 @@ impl ParsedRXingResult for ExpandedProductParsedRXingResult {
|
|||||||
|
|
||||||
impl ExpandedProductParsedRXingResult {
|
impl ExpandedProductParsedRXingResult {
|
||||||
pub const KILOGRAM: &'static str = "KG";
|
pub const KILOGRAM: &'static str = "KG";
|
||||||
pub const POUND: &'static str = "LB";
|
pub const POUND: &'static str = "LB";
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
rawText: String,
|
rawText: String,
|
||||||
|
|||||||
@@ -120,7 +120,10 @@ impl GeoParsedRXingResult {
|
|||||||
|
|
||||||
impl PartialEq for GeoParsedRXingResult {
|
impl PartialEq for GeoParsedRXingResult {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.latitude == other.latitude && self.longitude == other.longitude && self.altitude == other.altitude && self.query == other.query
|
self.latitude == other.latitude
|
||||||
|
&& self.longitude == other.longitude
|
||||||
|
&& self.altitude == other.altitude
|
||||||
|
&& self.query == other.query
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Eq for GeoParsedRXingResult{}
|
impl Eq for GeoParsedRXingResult {}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use super::ParsedRXingResult;
|
|||||||
*
|
*
|
||||||
* @author jbreiden@google.com (Jeff Breidenbach)
|
* @author jbreiden@google.com (Jeff Breidenbach)
|
||||||
*/
|
*/
|
||||||
#[derive(PartialEq, Eq,Hash,Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct ISBNParsedRXingResult {
|
pub struct ISBNParsedRXingResult {
|
||||||
isbn: String,
|
isbn: String,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use super::{ParsedRXingResult, ParsedRXingResultType};
|
|||||||
*
|
*
|
||||||
* @author dswitkin@google.com (Daniel Switkin)
|
* @author dswitkin@google.com (Daniel Switkin)
|
||||||
*/
|
*/
|
||||||
#[derive(PartialEq, Eq,Hash,Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct ProductParsedRXingResult {
|
pub struct ProductParsedRXingResult {
|
||||||
product_id: String,
|
product_id: String,
|
||||||
normalized_product_id: String,
|
normalized_product_id: String,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ use super::{ParsedRXingResult, ParsedRXingResultType, ResultParser};
|
|||||||
*
|
*
|
||||||
* @author Sean Owen
|
* @author Sean Owen
|
||||||
*/
|
*/
|
||||||
#[derive(PartialEq, Eq,Hash,Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct SMSParsedRXingResult {
|
pub struct SMSParsedRXingResult {
|
||||||
numbers: Vec<String>,
|
numbers: Vec<String>,
|
||||||
vias: Vec<String>,
|
vias: Vec<String>,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use super::{ParsedRXingResult, ParsedRXingResultType};
|
|||||||
*
|
*
|
||||||
* @author Sean Owen
|
* @author Sean Owen
|
||||||
*/
|
*/
|
||||||
#[derive(PartialEq, Eq,Hash,Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct TelParsedRXingResult {
|
pub struct TelParsedRXingResult {
|
||||||
number: String,
|
number: String,
|
||||||
telURI: String,
|
telURI: String,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ use super::{ParsedRXingResult, ParsedRXingResultType};
|
|||||||
*
|
*
|
||||||
* @author Sean Owen
|
* @author Sean Owen
|
||||||
*/
|
*/
|
||||||
#[derive(PartialEq, Eq,Hash, Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct TextParsedRXingResult {
|
pub struct TextParsedRXingResult {
|
||||||
text: String,
|
text: String,
|
||||||
language: String,
|
language: String,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use super::{ParsedRXingResult, ParsedRXingResultType, ResultParser, URIResultPar
|
|||||||
*
|
*
|
||||||
* @author Sean Owen
|
* @author Sean Owen
|
||||||
*/
|
*/
|
||||||
#[derive(PartialEq, Eq,Hash,Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct URIParsedRXingResult {
|
pub struct URIParsedRXingResult {
|
||||||
uri: String,
|
uri: String,
|
||||||
title: String,
|
title: String,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use super::{ParsedRXingResult, ParsedRXingResultType};
|
|||||||
/**
|
/**
|
||||||
* Represents a parsed result that encodes a Vehicle Identification Number (VIN).
|
* Represents a parsed result that encodes a Vehicle Identification Number (VIN).
|
||||||
*/
|
*/
|
||||||
#[derive(PartialEq, Eq,Hash,Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct VINParsedRXingResult {
|
pub struct VINParsedRXingResult {
|
||||||
vin: String,
|
vin: String,
|
||||||
world_manufacturer_id: String,
|
world_manufacturer_id: String,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use super::{ParsedRXingResult, ParsedRXingResultType, ResultParser};
|
|||||||
*
|
*
|
||||||
* @author Vikram Aggarwal
|
* @author Vikram Aggarwal
|
||||||
*/
|
*/
|
||||||
#[derive(PartialEq, Eq,Hash,Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct WifiParsedRXingResult {
|
pub struct WifiParsedRXingResult {
|
||||||
ssid: String,
|
ssid: String,
|
||||||
networkEncryption: String,
|
networkEncryption: String,
|
||||||
|
|||||||
@@ -29,52 +29,69 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::{rc::Rc, collections::HashMap};
|
use std::{collections::HashMap, rc::Rc};
|
||||||
|
|
||||||
use crate::{client::result::{ExpandedProductParsedRXingResult, ParsedClientResult}, common::{BitArray, GlobalHistogramBinarizer}, BinaryBitmap, BufferedImageLuminanceSource, BarcodeFormat, oned::{rss::expanded::RSSExpandedReader, OneDReader}};
|
use crate::{
|
||||||
|
client::result::{ExpandedProductParsedRXingResult, ParsedClientResult},
|
||||||
|
common::{BitArray, GlobalHistogramBinarizer},
|
||||||
|
oned::{rss::expanded::RSSExpandedReader, OneDReader},
|
||||||
|
BarcodeFormat, BinaryBitmap, BufferedImageLuminanceSource,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||||
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
|
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#[test]
|
||||||
#[test]
|
fn testDecodeRow2result2() {
|
||||||
fn testDecodeRow2result2() {
|
|
||||||
// (01)90012345678908(3103)001750
|
// (01)90012345678908(3103)001750
|
||||||
let expected =
|
let expected = ExpandedProductParsedRXingResult::new(
|
||||||
ExpandedProductParsedRXingResult::new("(01)90012345678908(3103)001750".to_owned(),
|
"(01)90012345678908(3103)001750".to_owned(),
|
||||||
"90012345678908".to_owned(),
|
"90012345678908".to_owned(),
|
||||||
"".to_owned(), "".to_owned(), "".to_owned(), "".to_owned(), "".to_owned(), "".to_owned(),
|
"".to_owned(),
|
||||||
"001750".to_owned(),
|
"".to_owned(),
|
||||||
ExpandedProductParsedRXingResult::KILOGRAM.to_owned(),
|
"".to_owned(),
|
||||||
"3".to_owned(), "".to_owned(), "".to_owned(), "".to_owned(), HashMap::new());
|
"".to_owned(),
|
||||||
|
"".to_owned(),
|
||||||
|
"".to_owned(),
|
||||||
|
"001750".to_owned(),
|
||||||
|
ExpandedProductParsedRXingResult::KILOGRAM.to_owned(),
|
||||||
|
"3".to_owned(),
|
||||||
|
"".to_owned(),
|
||||||
|
"".to_owned(),
|
||||||
|
"".to_owned(),
|
||||||
|
HashMap::new(),
|
||||||
|
);
|
||||||
|
|
||||||
assertCorrectImage2result("2.png", expected);
|
assertCorrectImage2result("2.png", expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assertCorrectImage2result( fileName:&str, expected:ExpandedProductParsedRXingResult)
|
fn assertCorrectImage2result(fileName: &str, expected: ExpandedProductParsedRXingResult) {
|
||||||
{
|
let path = format!("test_resources/blackbox/rssexpanded-1/{}", fileName);
|
||||||
let path = format!("test_resources/blackbox/rssexpanded-1/{}",fileName);
|
|
||||||
|
|
||||||
let image = image::open(path).expect("image must exist");
|
let image = image::open(path).expect("image must exist");
|
||||||
let binaryMap = BinaryBitmap::new(Rc::new(GlobalHistogramBinarizer::new(Box::new(BufferedImageLuminanceSource::new(image)))));
|
let binaryMap = BinaryBitmap::new(Rc::new(GlobalHistogramBinarizer::new(Box::new(
|
||||||
|
BufferedImageLuminanceSource::new(image),
|
||||||
|
))));
|
||||||
let rowNumber = binaryMap.getHeight() as usize / 2;
|
let rowNumber = binaryMap.getHeight() as usize / 2;
|
||||||
let row = binaryMap.getBlackRow(rowNumber, &mut BitArray::new()).expect("get row");
|
let row = binaryMap
|
||||||
|
.getBlackRow(rowNumber, &mut BitArray::new())
|
||||||
|
.expect("get row");
|
||||||
|
|
||||||
let mut rssExpandedReader = RSSExpandedReader::new();
|
let mut rssExpandedReader = RSSExpandedReader::new();
|
||||||
let theRXingResult= rssExpandedReader.decodeRow(rowNumber as u32, &row, &HashMap::new()).expect("must decode");
|
let theRXingResult = rssExpandedReader
|
||||||
|
.decodeRow(rowNumber as u32, &row, &HashMap::new())
|
||||||
|
.expect("must decode");
|
||||||
|
|
||||||
|
|
||||||
assert_eq!(&BarcodeFormat::RSS_EXPANDED, theRXingResult.getBarcodeFormat());
|
assert_eq!(
|
||||||
|
&BarcodeFormat::RSS_EXPANDED,
|
||||||
|
theRXingResult.getBarcodeFormat()
|
||||||
|
);
|
||||||
|
|
||||||
let ParsedClientResult::ExpandedProductResult(result) = crate::client::result::parseRXingResult(&theRXingResult) else {
|
let ParsedClientResult::ExpandedProductResult(result) = crate::client::result::parseRXingResult(&theRXingResult) else {
|
||||||
panic!("incorrect result type found");
|
panic!("incorrect result type found");
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(expected, result);
|
assert_eq!(expected, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use rxing::{
|
use rxing::{oned::CodaBarReader, BarcodeFormat};
|
||||||
oned::{CodaBarReader},
|
|
||||||
BarcodeFormat,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
use rxing::{
|
use rxing::{BarcodeFormat, MultiFormatReader};
|
||||||
BarcodeFormat, MultiFormatReader,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
use rxing::{
|
use rxing::{oned::Code39Reader, BarcodeFormat, MultiFormatReader};
|
||||||
oned::{Code39Reader},
|
|
||||||
BarcodeFormat, MultiFormatReader,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use rxing::{
|
use rxing::{BarcodeFormat, MultiFormatReader};
|
||||||
BarcodeFormat, MultiFormatReader,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use rxing::{
|
use rxing::{BarcodeFormat, MultiFormatReader};
|
||||||
BarcodeFormat, MultiFormatReader,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use rxing::{
|
use rxing::{BarcodeFormat, MultiFormatReader};
|
||||||
BarcodeFormat, MultiFormatReader,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use rxing::{
|
use rxing::{BarcodeFormat, MultiFormatReader};
|
||||||
BarcodeFormat, MultiFormatReader,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user