use crate::*;
pub mod yandex;
pub use yandex::Yandex;
pub trait Api {
fn new() -> Self;
fn translate(
&self,
text: String,
source_language: InputLanguage,
target_language: Language,
) -> Result<String, Error>;
}
pub trait ApiDetect: Api {
fn detect(&self, text: String) -> Result<Option<Language>, Error>;
}
pub trait ApiKey<'a>: Api + Sized {
fn set_set(&mut self, key: &'a str);
fn get_key(&self) -> Option<&'a str>;
}
trait ApiTranslateResponse {
fn get_text(&self) -> String;
}
trait ApiDetectResponse {
fn get_lang(&self) -> Option<Language>;
}
pub trait ApiError {
fn from_error_code(code: u16) -> Self;
fn to_error_code(&self) -> u16;
}