Struct OpenCC

Source
pub struct OpenCC { /* private fields */ }
Expand description

核心的 OpenCC 转换器

Implementations§

Source§

impl OpenCC

Source

pub fn new<P: AsRef<Path>>(config_path: P) -> Result<Self>

从配置文件创建一个新的 OpenCC 实例。 解析 JSON 配置文件,加载所有必需的词典,并构建转换流程。

§参数
  • config_path: 指向主 JSON 配置文件(例如 s2t.json)的路径
§返回

一个 Result,其中包含新的 OpenCC 实例,或者在加载失败时返回错误

Source

pub fn convert(&self, input: &str) -> String

根据加载的配置转换字符串

§参数
  • input: 需要转换的字符串
§返回

转换后的字符串

Source

pub fn name(&self) -> &str

返回当前加载的配置名称

Auto Trait Implementations§

§

impl Freeze for OpenCC

§

impl !RefUnwindSafe for OpenCC

§

impl Send for OpenCC

§

impl Sync for OpenCC

§

impl Unpin for OpenCC

§

impl !UnwindSafe for OpenCC

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, 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.