XlsxToMdError

Enum XlsxToMdError 

Source
pub enum XlsxToMdError {
    Io(Error),
    Parse(Error),
    Utf8(Utf8Error),
    Zip(String),
    ParseInt(ParseIntError),
    Config(String),
    UnsupportedFeature {
        sheet: String,
        cell: String,
        message: String,
    },
    SecurityViolation(String),
}
Expand description

xlsxzeroクレート全体で使用するエラー型

このエラー型は、Excelファイルの読み込み、解析、変換処理中に発生する すべてのエラーを統一的に扱うために使用されます。

§エラーの種類

  • Io: I/O操作中に発生したエラー(ファイル読み込み失敗など)
  • Parse: Excelファイルの解析中に発生したエラー(calamine由来)
  • Config: 設定の検証に失敗したエラー(無効な範囲指定など)
  • UnsupportedFeature: サポートされていない機能が検出されたエラー

§使用例

use xlsxzero::XlsxToMdError;
use std::fs::File;

fn read_excel_file(path: &str) -> Result<(), XlsxToMdError> {
    let file = File::open(path)?;  // Ioエラーが自動的に変換される
    // ... 処理 ...
    Ok(())
}

Variants§

§

Io(Error)

I/O操作中に発生したエラー

ファイルの読み込み失敗、書き込み失敗など、標準ライブラリの std::io::Errorが発生した場合に使用されます。

#[from]属性により、std::io::Errorから自動的に変換されます。

§

Parse(Error)

Excelファイルの解析中に発生したエラー

calamineクレートがExcelファイルを解析する際に発生したエラーです。 ファイル形式が不正、破損したファイル、サポートされていない形式などが 原因となります。

#[from]属性により、calamine::Errorから自動的に変換されます。

§

Utf8(Utf8Error)

UTF-8文字列の変換エラー

XML解析時にUTF-8文字列への変換に失敗した場合に発生します。

§

Zip(String)

ZIPアーカイブの解析エラー

XLSXファイル(ZIPアーカイブ)の解析中に発生したエラーです。

§

ParseInt(ParseIntError)

数値の解析エラー

文字列から数値への変換に失敗した場合に発生します。

§

Config(String)

設定の検証に失敗したエラー

ConverterBuilder::build()時に設定を検証し、無効な設定が検出された 場合に発生します。例えば、セル範囲の開始座標が終了座標より大きい場合や、 カスタム日付形式が不正な場合などです。

§

use xlsxzero::{ConverterBuilder, XlsxToMdError};

let result = ConverterBuilder::new()
    .with_range((10, 0), (0, 0))  // 無効な範囲
    .build();

match result {
    Err(XlsxToMdError::Config(msg)) => {
        println!("設定エラー: {}", msg);
    }
    _ => {}
}
§

UnsupportedFeature

サポートされていない機能が検出されたエラー

Phase Iでは実装されていない機能(例: ピボットテーブル、高度な数式など) が検出された場合に発生します。エラーメッセージには、シート名、セル座標、 詳細なメッセージが含まれます。

§

use xlsxzero::XlsxToMdError;

let error = XlsxToMdError::UnsupportedFeature {
    sheet: "Sheet1".to_string(),
    cell: "A1".to_string(),
    message: "Pivot table is not supported in Phase I".to_string(),
};

println!("{}", error);
// 出力: "Unsupported feature at sheet 'Sheet1', cell A1: Pivot table is not supported in Phase I"

Fields

§sheet: String

エラーが発生したシート名

§cell: String

エラーが発生したセルの座標(A1記法)

§message: String

エラーの詳細メッセージ

§

SecurityViolation(String)

セキュリティ制限に違反したエラー

ZIP bomb攻撃、パストラバーサル攻撃、ファイルサイズ制限などの セキュリティ制限に違反した場合に発生します。

§

use xlsxzero::XlsxToMdError;

let error = XlsxToMdError::SecurityViolation(
    "File size exceeds maximum allowed size".to_string()
);

Trait Implementations§

Source§

impl Debug for XlsxToMdError

Source§

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

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

impl Display for XlsxToMdError

Source§

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

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

impl Error for XlsxToMdError

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
Source§

impl From<Error> for XlsxToMdError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for XlsxToMdError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<ParseIntError> for XlsxToMdError

Source§

fn from(source: ParseIntError) -> Self

Converts to this type from the input type.
Source§

impl From<Utf8Error> for XlsxToMdError

Source§

fn from(source: Utf8Error) -> Self

Converts to this type from the input type.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = 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.