mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
add basic serde support
This commit is contained in:
@@ -18,11 +18,15 @@
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/**
|
||||
* Enumerates barcode formats known to this package. Please keep alphabetized.
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
|
||||
pub enum BarcodeFormat {
|
||||
/** Aztec 2D barcode format. */
|
||||
|
||||
@@ -14,10 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/**
|
||||
* Enumeration for DataMatrix symbol shape hint. It can be used to force square or rectangular
|
||||
* symbols.
|
||||
*/
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub enum SymbolShapeHint {
|
||||
FORCE_NONE,
|
||||
|
||||
@@ -20,6 +20,9 @@ use std::collections::HashSet;
|
||||
|
||||
use crate::{BarcodeFormat, RXingResultPointCallback};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/**
|
||||
* Encapsulates a type of hint that a caller may pass to a barcode reader to help it
|
||||
* more quickly or accurately decode it. It is up to implementations to decide what,
|
||||
@@ -29,6 +32,7 @@ use crate::{BarcodeFormat, RXingResultPointCallback};
|
||||
* @author dswitkin@google.com (Daniel Switkin)
|
||||
* @see Reader#decode(BinaryBitmap,java.util.Map)
|
||||
*/
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Eq, PartialEq, Hash, Debug, Clone, Copy)]
|
||||
pub enum DecodeHintType {
|
||||
/**
|
||||
@@ -137,6 +141,7 @@ pub enum DecodeHintType {
|
||||
}*/
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Clone)]
|
||||
pub enum DecodeHintValue {
|
||||
/**
|
||||
@@ -196,6 +201,7 @@ pub enum DecodeHintValue {
|
||||
* The caller needs to be notified via callback when a possible {@link RXingResultPoint}
|
||||
* is found. Maps to a {@link RXingResultPointCallback}.
|
||||
*/
|
||||
#[cfg_attr(feature = "serde", serde(skip_serializing, skip_deserializing))]
|
||||
NeedResultPointCallback(RXingResultPointCallback),
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,9 +20,13 @@ use std::fmt;
|
||||
|
||||
use crate::Exceptions;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/**
|
||||
* Simply encapsulates a width and height.
|
||||
*/
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Eq, PartialEq, Hash, Copy, Clone)]
|
||||
pub struct Dimension(usize, usize);
|
||||
|
||||
|
||||
@@ -18,11 +18,15 @@
|
||||
|
||||
use crate::{pdf417::encoder::Dimensions, Dimension};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/**
|
||||
* These are a set of hints that you may pass to Writers to specify their behavior.
|
||||
*
|
||||
* @author dswitkin@google.com (Daniel Switkin)
|
||||
*/
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
|
||||
pub enum EncodeHintType {
|
||||
/**
|
||||
@@ -176,6 +180,7 @@ pub enum EncodeHintType {
|
||||
CODE128_COMPACT,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub enum EncodeHintValue {
|
||||
/**
|
||||
* Specifies what degree of error correction to use, for example in QR Codes.
|
||||
|
||||
@@ -14,11 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/**
|
||||
* Data object to specify the minimum and maximum number of rows and columns for a PDF417 barcode.
|
||||
*
|
||||
* @author qwandor@google.com (Andrew Walbran)
|
||||
*/
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||
pub struct Dimensions {
|
||||
minCols: usize,
|
||||
|
||||
@@ -14,9 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/**
|
||||
* @author Guenther Grau
|
||||
*/
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct PDF417RXingResultMetadata {
|
||||
segmentIndex: usize,
|
||||
|
||||
@@ -14,20 +14,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
//package com.google.zxing;
|
||||
|
||||
//import java.util.EnumMap;
|
||||
//import java.util.Map;
|
||||
|
||||
use std::{collections::HashMap, fmt};
|
||||
|
||||
use crate::{BarcodeFormat, RXingResultMetadataType, RXingResultMetadataValue, RXingResultPoint};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/**
|
||||
* <p>Encapsulates the result of decoding a barcode within an image.</p>
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Clone)]
|
||||
pub struct RXingResult {
|
||||
text: String,
|
||||
|
||||
@@ -20,12 +20,16 @@ use std::rc::Rc;
|
||||
|
||||
use crate::pdf417::PDF417RXingResultMetadata;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/**
|
||||
* Represents some type of metadata about the result of the decoding that the decoder
|
||||
* wishes to communicate back to the caller.
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Eq, PartialEq, Hash, Debug, Clone)]
|
||||
pub enum RXingResultMetadataType {
|
||||
/**
|
||||
@@ -126,6 +130,7 @@ impl From<String> for RXingResultMetadataType {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum RXingResultMetadataValue {
|
||||
/**
|
||||
|
||||
@@ -3,12 +3,16 @@ use std::{fmt, iter::Sum};
|
||||
use crate::ResultPoint;
|
||||
use std::hash::Hash;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/**
|
||||
* <p>Encapsulates a point of interest in an image containing a barcode. Typically, this
|
||||
* would be the location of a finder pattern or the corner of the barcode, for example.</p>
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct RXingResultPoint {
|
||||
pub(crate) x: f32,
|
||||
|
||||
Reference in New Issue
Block a user