[−][src]Struct wordfeud_solver::Codec
Translate from string to label codes and vice versa. Each wordfeud tile is translated to a code.
- 0: No tile (empty square)
- 1 .. 26:
a
..z
- 27 .. 31: Non-ascii tiles, depending on codec
- 64: Blank tile
*
(unassigned) - 65 .. 90:
A
..Z
(blank tile assigned toa
..z
) - 91 .. 95: Blank tile assigned, depending on codec
Implementations
impl Codec
[src]
pub fn new(extend: &[&str]) -> Codec
[src]
Return a new Codec
for "a".."z", "*", " ", extended with the non-ascii tiles from extend
.
Examples
use wordfeud_solver::Codec; let codec = Codec::new(&["ä", "ö", "ü"]);
pub fn encode(&self, word: &str) -> Result<Vec<u8>, Error>
[src]
Encode string, and return a list of u8
labels.
Errors
An error is returned if the string can not be encoded with the codec.
Examples
use wordfeud_solver::{Codec, Error}; let codec = Codec::new(&["ä", "ö", "ü"]); let labels = codec.encode("azAZä *")?; assert_eq!(labels, vec![1,26,65,90,27,0,64]);
pub fn decode(&self, codes: &[Code]) -> Vec<String>
[src]
Decode labels, and return a list of strings.
Errors
An error is returned if the labels can not be decoded with the codec.
Examples
use wordfeud_solver::{Codec, Error}; let codec = Codec::new(&["ä", "ö", "ü"]); let labels = &[1,26,65,90,27,0,64]; let decoded = codec.decode(labels); assert_eq!(decoded, &["a","z","A","Z","ä"," ", "*"]);
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Codec
impl Send for Codec
impl Sync for Codec
impl Unpin for Codec
impl UnwindSafe for Codec
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,