[][src]Trait phonics::PhonicsEncoder

pub trait PhonicsEncoder {
    fn new() -> Self;
fn encode(&self, word: &str) -> Result<String, PhonicsError>; }

A trait for phonetic encoding of a string.

Instances of PhonicsEncoder should provide an encoder for strings. It is not expected to maintain state as phonetic encoders do not typically include an updating mechanism.

Example

use phonics::PhonicsEncoder;

fn foo<E: PhonicsEncoder + ?Sized>(e: &mut E) -> String {
    return(e.encode("Scully").unwrap());
}

Required methods

fn new() -> Self

Return a new encoder.

This function should return a new instance of the phonetic encoder the the that implements this trait.

Example

use phonics::{Lein, PhonicsEncoder};

let mut enc = Lein::new();

fn encode(&self, word: &str) -> Result<String, PhonicsError>

Encode a string and return the result or error.

This function should encode a string according to the algorithm that implements this trait and return that string. Under certain circumstances, an error may return so the result is returned in a Result.

Example

use phonics::{Lein, PhonicsEncoder};

let mut enc = Lein::new();
enc.encode("Mulder");
Loading content...

Implementors

impl PhonicsEncoder for Lein[src]

impl<P: PhonicsEncoder> PhonicsEncoder for Phonics<P>[src]

Loading content...