Skip to main content

TableError

Enum TableError 

Source
pub enum TableError {
    MissingColumn {
        line: usize,
    },
    InvalidField {
        line: usize,
        field: &'static str,
        value: String,
    },
    SelfMapping {
        line: usize,
        ch: char,
    },
    DuplicateCandidate {
        line: usize,
        candidate: char,
        owner: char,
    },
    DuplicateSource {
        line: usize,
        ch: char,
    },
    ChainedCandidate {
        line: usize,
        candidate: char,
    },
}
Expand description

映射表解析失败的原因。每条都对应 Table::parse 的一条校验规则, 并且都带上出错的行号,方便直接定位到 TSV 的那一行。

Variants§

§

MissingColumn

规则 1:这一行没有 Tab 分隔出的第二列

Fields

§line: usize

出错行号,从 1 开始

§

InvalidField

规则 2:原字和每个候选都必须是恰好一个 char

Fields

§line: usize

出错行号,从 1 开始

§field: &'static str

出错的字段,"source" 或 "candidate"

§value: String

实际读到的内容

§

SelfMapping

规则 3:候选 ≠ 原字(映射到自身等于什么都没做,还会破坏反查)

Fields

§line: usize

出错行号,从 1 开始

§ch: char

把自己映射成自己的那个字

§

DuplicateCandidate

规则 4:候选全局唯一(否则反查有歧义)

Fields

§line: usize

出错行号,从 1 开始

§candidate: char

重复出现的候选

§owner: char

先占走这个候选的原字

§

DuplicateSource

规则 5:同一原字不重复出现

Fields

§line: usize

出错行号,从 1 开始

§ch: char

被重复定义的原字

§

ChainedCandidate

规则 6:候选不能同时是任何原字(否则 encode 后 decode 会套娃)

Fields

§line: usize

该字作为原字出现的行号,从 1 开始

§candidate: char

既是别人的候选、又是自己原字的那个字

Trait Implementations§

Source§

impl Debug for TableError

Source§

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

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

impl Display for TableError

Source§

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

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

impl Error for TableError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.