translation_api_cn/lib.rs
1#[cfg(feature = "baidu")]
2pub mod baidu;
3
4#[cfg(feature = "tencent")]
5pub mod tencent;
6
7#[cfg(feature = "niutrans")]
8pub mod niutrans;
9
10/// 单次调用各 API 时,被限制的“字符”单位
11///
12/// 对于百度翻译,为 Byte;对于腾讯云和小牛翻译,为 Char。
13#[derive(Debug, serde::Deserialize)]
14pub enum Limit {
15 #[serde(rename = "bytes")]
16 Byte(usize),
17 #[serde(rename = "chars")]
18 Char(usize),
19}
20
21impl Limit {
22 pub fn limit(&self) -> usize {
23 let (&Limit::Byte(l) | &Limit::Char(l)) = self;
24 l
25 }
26}