[][src]Trait text_translator::Api

pub trait Api {
    fn new() -> Self;
fn translate(
        &self,
        text: String,
        source_language: InputLanguage,
        target_language: Language
    ) -> Result<String, Error>; }

A trait defining a translate API.

Implements new() to return a new API, and translate() to translate a text.

Required methods

fn new() -> Self

Returns a new API struct, without initiating it.

fn translate(
    &self,
    text: String,
    source_language: InputLanguage,
    target_language: Language
) -> Result<String, Error>

Translates text between two languages.

Takes in input the selected text and two enums:

  • source_language: InputLanguage, representing either automatic language detection or a defined language;
  • target_language: Language, representing a defined language to output to.

Returns a Result containing either a String with the translated text, or an Error that happened during the process.

Loading content...

Implementors

impl<'a> Api for Yandex<'a>[src]

fn new() -> Self[src]

Returns a new Yandex struct without API key.

To set it, use with_key or set_key methods instead.

Loading content...