MinimalEncoder

Struct MinimalEncoder 

Source
pub struct MinimalEncoder { /* private fields */ }
Expand description

Encoder that encodes minimally

Algorithm:

The eleventh commandment was “Thou Shalt Compute” or “Thou Shalt Not Compute” - I forget which (Alan Perilis).

This implementation computes. As an alternative, the QR-Code specification suggests heuristics like this one:

If initial input data is in the exclusive subset of the Alphanumeric character set AND if there are less than [6,7,8] characters followed by data from the remainder of the 8-bit byte character set, THEN select the 8- bit byte mode ELSE select Alphanumeric mode;

This is probably right for 99.99% of cases but there is at least this one counter example: The string “AAAAAAa” encodes 2 bits smaller as ALPHANUMERIC(AAAAAA), BYTE(a) than by encoding it as BYTE(AAAAAAa). Perhaps that is the only counter example but without having proof, it remains unclear.

ECI switching:

In multi language content the algorithm selects the most compact representation using ECI modes. For example the most compact representation of the string “\u0150\u015C” (O-double-acute, S-circumflex) is ECI(UTF-8), BYTE(\u0150\u015C) while prepending one or more times the same leading character as in “\u0150\u0150\u015C”, the most compact representation uses two ECIs so that the string is encoded as ECI(ISO-8859-2), BYTE(\u0150\u0150), ECI(ISO-8859-3), BYTE(\u015C).

@author Alex Geller

Implementations§

Source§

impl MinimalEncoder

Source

pub fn new( stringToEncode: &str, priorityCharset: Option<CharacterSet>, isGS1: bool, ecLevel: ErrorCorrectionLevel, ) -> Self

Creates a MinimalEncoder

@param stringToEncode The string to encode @param priorityCharset The preferred {@link Charset}. When the value of the argument is null, the algorithm chooses charsets that leads to a minimal representation. Otherwise the algorithm will use the priority charset to encode any character in the input that can be encoded by it if the charset is among the supported charsets. @param isGS1 {@code true} if a FNC1 is to be prepended; {@code false} otherwise @param ecLevel The error correction level. @see RXingResultList#getVersion

Source

pub fn encode_with_details( stringToEncode: &str, version: Option<VersionRef>, priorityCharset: Option<CharacterSet>, isGS1: bool, ecLevel: ErrorCorrectionLevel, ) -> Result<RXingResultList>

Encodes the string minimally

@param stringToEncode The string to encode @param version The preferred {@link Version}. A minimal version is computed (see {@link RXingResultList#getVersion method} when the value of the argument is null @param priorityCharset The preferred {@link Charset}. When the value of the argument is null, the algorithm chooses charsets that leads to a minimal representation. Otherwise the algorithm will use the priority charset to encode any character in the input that can be encoded by it if the charset is among the supported charsets. @param isGS1 {@code true} if a FNC1 is to be prepended; {@code false} otherwise @param ecLevel The error correction level. @return An instance of {@code RXingResultList} representing the minimal solution. @see RXingResultList#getBits @see RXingResultList#getVersion @see RXingResultList#getSize

Source

pub fn encode(&self, version: Option<VersionRef>) -> Result<RXingResultList>

Source

pub fn getVersionSize(version: VersionRef) -> VersionSize

Source

pub fn getVersion(versionSize: VersionSize) -> Result<VersionRef>

Source

pub fn isNumeric(c: &str) -> bool

Source

pub fn isDoubleByteKanji(c: &str) -> bool

Source

pub fn isAlphanumeric(c: &str) -> bool

Source

pub fn canEncode(&self, mode: &Mode, c: &str) -> bool

Source

pub fn getCompactedOrdinal(mode: Option<Mode>) -> Result<u32>

Source

pub fn addEdge( &self, edges: &mut [Vec<Vec<Option<Arc<Edge>>>>], position: usize, edge: Option<Arc<Edge>>, ) -> Result<()>

Source

pub fn addEdges( &self, version: VersionRef, edges: &mut [Vec<Vec<Option<Arc<Edge>>>>], from: usize, previous: Option<Arc<Edge>>, ) -> Result<()>

Source

pub fn encodeSpecificVersion( &self, version: VersionRef, ) -> Result<RXingResultList>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V