[][src]Struct wordfeud_solver::Codec

pub struct Codec { /* fields omitted */ }

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 to a..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

impl Clone for Codec[src]

impl Debug for Codec[src]

impl Default for Codec[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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