magick_rust/result.rs
1/*
2 * Copyright 2021-2024 DCJanus
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16use std::fmt::{Debug, Display, Formatter};
17
18pub type Result<T> = std::result::Result<T, MagickError>;
19
20#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Hash)]
21pub struct MagickError(pub String);
22
23impl From<&'static str> for MagickError {
24 fn from(s: &'static str) -> Self {
25 MagickError(s.to_string())
26 }
27}
28
29impl Display for MagickError {
30 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
31 Display::fmt(&self.0, f)
32 }
33}
34
35impl std::error::Error for MagickError {}