pub struct AlphanumericStepper<T = u32> { /* private fields */ }Expand description
A reversible alphanumeric sequence codec for compact serial codes like 000..999, A00..Z99, AA0..ZZ9, and AAA..ZZZ.
Implementations§
Source§impl<T: Copy> AlphanumericStepper<T>
impl<T: Copy> AlphanumericStepper<T>
Sourcepub fn max_number(&self) -> T
pub fn max_number(&self) -> T
Returns the maximum number that can be encoded.
Source§impl AlphanumericStepper<u8>
impl AlphanumericStepper<u8>
Sourcepub fn new(width: usize) -> Result<Self, AlphanumericStepperBuildError>
pub fn new(width: usize) -> Result<Self, AlphanumericStepperBuildError>
Creates a new AlphanumericStepper instance with the specified width.
Sourcepub fn encode(
&self,
number: u8,
) -> Result<String, AlphanumericStepperEncodeError>
pub fn encode( &self, number: u8, ) -> Result<String, AlphanumericStepperEncodeError>
Encodes a number into a string.
Sourcepub fn encode_to_string(
&self,
number: u8,
s: &mut String,
) -> Result<(), AlphanumericStepperEncodeError>
pub fn encode_to_string( &self, number: u8, s: &mut String, ) -> Result<(), AlphanumericStepperEncodeError>
Encodes a number and appends the result to a string.
Sourcepub fn encode_to_vec(
&self,
number: u8,
v: &mut Vec<u8>,
) -> Result<(), AlphanumericStepperEncodeError>
pub fn encode_to_vec( &self, number: u8, v: &mut Vec<u8>, ) -> Result<(), AlphanumericStepperEncodeError>
Encodes a number and appends the result to a byte vector.
Sourcepub fn encode_to_writer<W>(
&self,
number: u8,
writer: &mut W,
) -> Result<(), AlphanumericStepperEncodeWriteError>
Available on crate feature std only.
pub fn encode_to_writer<W>( &self, number: u8, writer: &mut W, ) -> Result<(), AlphanumericStepperEncodeWriteError>
std only.Encodes a number and writes the result to an I/O writer.
Source§impl AlphanumericStepper<u16>
impl AlphanumericStepper<u16>
Sourcepub fn new(width: usize) -> Result<Self, AlphanumericStepperBuildError>
pub fn new(width: usize) -> Result<Self, AlphanumericStepperBuildError>
Creates a new AlphanumericStepper instance with the specified width.
Sourcepub fn encode(
&self,
number: u16,
) -> Result<String, AlphanumericStepperEncodeError>
pub fn encode( &self, number: u16, ) -> Result<String, AlphanumericStepperEncodeError>
Encodes a number into a string.
Sourcepub fn encode_to_string(
&self,
number: u16,
s: &mut String,
) -> Result<(), AlphanumericStepperEncodeError>
pub fn encode_to_string( &self, number: u16, s: &mut String, ) -> Result<(), AlphanumericStepperEncodeError>
Encodes a number and appends the result to a string.
Sourcepub fn encode_to_vec(
&self,
number: u16,
v: &mut Vec<u8>,
) -> Result<(), AlphanumericStepperEncodeError>
pub fn encode_to_vec( &self, number: u16, v: &mut Vec<u8>, ) -> Result<(), AlphanumericStepperEncodeError>
Encodes a number and appends the result to a byte vector.
Sourcepub fn encode_to_writer<W>(
&self,
number: u16,
writer: &mut W,
) -> Result<(), AlphanumericStepperEncodeWriteError>
Available on crate feature std only.
pub fn encode_to_writer<W>( &self, number: u16, writer: &mut W, ) -> Result<(), AlphanumericStepperEncodeWriteError>
std only.Encodes a number and writes the result to an I/O writer.
Source§impl AlphanumericStepper<u32>
impl AlphanumericStepper<u32>
Sourcepub fn new(width: usize) -> Result<Self, AlphanumericStepperBuildError>
pub fn new(width: usize) -> Result<Self, AlphanumericStepperBuildError>
Creates a new AlphanumericStepper instance with the specified width.
Sourcepub fn encode(
&self,
number: u32,
) -> Result<String, AlphanumericStepperEncodeError>
pub fn encode( &self, number: u32, ) -> Result<String, AlphanumericStepperEncodeError>
Encodes a number into a string.
Sourcepub fn encode_to_string(
&self,
number: u32,
s: &mut String,
) -> Result<(), AlphanumericStepperEncodeError>
pub fn encode_to_string( &self, number: u32, s: &mut String, ) -> Result<(), AlphanumericStepperEncodeError>
Encodes a number and appends the result to a string.
Sourcepub fn encode_to_vec(
&self,
number: u32,
v: &mut Vec<u8>,
) -> Result<(), AlphanumericStepperEncodeError>
pub fn encode_to_vec( &self, number: u32, v: &mut Vec<u8>, ) -> Result<(), AlphanumericStepperEncodeError>
Encodes a number and appends the result to a byte vector.
Sourcepub fn encode_to_writer<W>(
&self,
number: u32,
writer: &mut W,
) -> Result<(), AlphanumericStepperEncodeWriteError>
Available on crate feature std only.
pub fn encode_to_writer<W>( &self, number: u32, writer: &mut W, ) -> Result<(), AlphanumericStepperEncodeWriteError>
std only.Encodes a number and writes the result to an I/O writer.
Source§impl AlphanumericStepper<u64>
impl AlphanumericStepper<u64>
Sourcepub fn new(width: usize) -> Result<Self, AlphanumericStepperBuildError>
pub fn new(width: usize) -> Result<Self, AlphanumericStepperBuildError>
Creates a new AlphanumericStepper instance with the specified width.
Sourcepub fn encode(
&self,
number: u64,
) -> Result<String, AlphanumericStepperEncodeError>
pub fn encode( &self, number: u64, ) -> Result<String, AlphanumericStepperEncodeError>
Encodes a number into a string.
Sourcepub fn encode_to_string(
&self,
number: u64,
s: &mut String,
) -> Result<(), AlphanumericStepperEncodeError>
pub fn encode_to_string( &self, number: u64, s: &mut String, ) -> Result<(), AlphanumericStepperEncodeError>
Encodes a number and appends the result to a string.
Sourcepub fn encode_to_vec(
&self,
number: u64,
v: &mut Vec<u8>,
) -> Result<(), AlphanumericStepperEncodeError>
pub fn encode_to_vec( &self, number: u64, v: &mut Vec<u8>, ) -> Result<(), AlphanumericStepperEncodeError>
Encodes a number and appends the result to a byte vector.
Sourcepub fn encode_to_writer<W>(
&self,
number: u64,
writer: &mut W,
) -> Result<(), AlphanumericStepperEncodeWriteError>
Available on crate feature std only.
pub fn encode_to_writer<W>( &self, number: u64, writer: &mut W, ) -> Result<(), AlphanumericStepperEncodeWriteError>
std only.Encodes a number and writes the result to an I/O writer.
Source§impl AlphanumericStepper<u128>
impl AlphanumericStepper<u128>
Sourcepub fn new(width: usize) -> Result<Self, AlphanumericStepperBuildError>
pub fn new(width: usize) -> Result<Self, AlphanumericStepperBuildError>
Creates a new AlphanumericStepper instance with the specified width.
Sourcepub fn encode(
&self,
number: u128,
) -> Result<String, AlphanumericStepperEncodeError>
pub fn encode( &self, number: u128, ) -> Result<String, AlphanumericStepperEncodeError>
Encodes a number into a string.
Sourcepub fn encode_to_string(
&self,
number: u128,
s: &mut String,
) -> Result<(), AlphanumericStepperEncodeError>
pub fn encode_to_string( &self, number: u128, s: &mut String, ) -> Result<(), AlphanumericStepperEncodeError>
Encodes a number and appends the result to a string.
Sourcepub fn encode_to_vec(
&self,
number: u128,
v: &mut Vec<u8>,
) -> Result<(), AlphanumericStepperEncodeError>
pub fn encode_to_vec( &self, number: u128, v: &mut Vec<u8>, ) -> Result<(), AlphanumericStepperEncodeError>
Encodes a number and appends the result to a byte vector.
Sourcepub fn encode_to_writer<W>(
&self,
number: u128,
writer: &mut W,
) -> Result<(), AlphanumericStepperEncodeWriteError>
Available on crate feature std only.
pub fn encode_to_writer<W>( &self, number: u128, writer: &mut W, ) -> Result<(), AlphanumericStepperEncodeWriteError>
std only.Encodes a number and writes the result to an I/O writer.
Source§impl AlphanumericStepper<usize>
impl AlphanumericStepper<usize>
Sourcepub fn new(width: usize) -> Result<Self, AlphanumericStepperBuildError>
pub fn new(width: usize) -> Result<Self, AlphanumericStepperBuildError>
Creates a new AlphanumericStepper instance with the specified width.
Sourcepub fn encode(
&self,
number: usize,
) -> Result<String, AlphanumericStepperEncodeError>
pub fn encode( &self, number: usize, ) -> Result<String, AlphanumericStepperEncodeError>
Encodes a number into a string.
Sourcepub fn encode_to_string(
&self,
number: usize,
s: &mut String,
) -> Result<(), AlphanumericStepperEncodeError>
pub fn encode_to_string( &self, number: usize, s: &mut String, ) -> Result<(), AlphanumericStepperEncodeError>
Encodes a number and appends the result to a string.
Sourcepub fn encode_to_vec(
&self,
number: usize,
v: &mut Vec<u8>,
) -> Result<(), AlphanumericStepperEncodeError>
pub fn encode_to_vec( &self, number: usize, v: &mut Vec<u8>, ) -> Result<(), AlphanumericStepperEncodeError>
Encodes a number and appends the result to a byte vector.
Sourcepub fn encode_to_writer<W>(
&self,
number: usize,
writer: &mut W,
) -> Result<(), AlphanumericStepperEncodeWriteError>
Available on crate feature std only.
pub fn encode_to_writer<W>( &self, number: usize, writer: &mut W, ) -> Result<(), AlphanumericStepperEncodeWriteError>
std only.Encodes a number and writes the result to an I/O writer.
Trait Implementations§
Source§impl<T: Clone> Clone for AlphanumericStepper<T>
impl<T: Clone> Clone for AlphanumericStepper<T>
Source§fn clone(&self) -> AlphanumericStepper<T>
fn clone(&self) -> AlphanumericStepper<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug> Debug for AlphanumericStepper<T>
impl<T: Debug> Debug for AlphanumericStepper<T>
impl<T: Eq> Eq for AlphanumericStepper<T>
Source§impl<T: PartialEq> PartialEq for AlphanumericStepper<T>
impl<T: PartialEq> PartialEq for AlphanumericStepper<T>
Source§fn eq(&self, other: &AlphanumericStepper<T>) -> bool
fn eq(&self, other: &AlphanumericStepper<T>) -> bool
self and other values to be equal, and is used by ==.