Query

Struct Query 

Source
pub struct Query<'q> {
    pub from: &'q str,
    pub to: &'q str,
    pub projectid: u8,
    pub q: &'q [&'q str],
}
Expand description

翻译前的必要信息

https://cloud.tencent.com/document/product/551/40566

Fields§

§from: &'q str

翻译源语言,可设置为 auto

TODO:变成 enum 类型

§to: &'q str

翻译目标语言,不可设置为 auto

TODO:和 from 共用 enum 类型,但是并非任意两个语言之间可以互译。 比如 ar(阿拉伯语):en(英语) 表明阿拉伯语只能从英语中翻译过去。 请求翻译 query,必须为 UTF-8 编码。

TODO: 在传入之前应该把文字控制在 2000 以内, 一个汉字、一个字母、一个标点都计为一个字符, 超过 2000 字节要分段请求。

§projectid: u8§q: &'q [&'q str]

Implementations§

Source§

impl<'q> Query<'q>

Source

pub fn new(q: &'q [&'q str], from: &'q str, to: &'q str, projectid: u8) -> Self

Source

pub fn to_hashed(&self) -> Result<String>

Source

pub fn to_json_string(&self) -> Result<String>

Trait Implementations§

Source§

impl<'q> Debug for Query<'q>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'q> Serialize for Query<'q>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'q> Freeze for Query<'q>

§

impl<'q> RefUnwindSafe for Query<'q>

§

impl<'q> Send for Query<'q>

§

impl<'q> Sync for Query<'q>

§

impl<'q> Unpin for Query<'q>

§

impl<'q> UnwindSafe for Query<'q>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.