summaryrefslogtreecommitdiff
path: root/iced_builder/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'iced_builder/src/lib.rs')
-rw-r--r--iced_builder/src/lib.rs38
1 files changed, 13 insertions, 25 deletions
diff --git a/iced_builder/src/lib.rs b/iced_builder/src/lib.rs
index 420b14c..14a044e 100644
--- a/iced_builder/src/lib.rs
+++ b/iced_builder/src/lib.rs
@@ -1,4 +1,5 @@
pub mod types;
+pub mod views;
use std::path::PathBuf;
@@ -7,41 +8,27 @@ use types::{
element_name::ElementName, project::Project, rendered_element::RenderedElement, DesignerPage,
};
-#[derive(Debug, Clone)]
+use thiserror::Error;
+
+#[derive(Debug, Clone, Error)]
pub enum Error {
- IOError(std::io::ErrorKind),
+ #[error("an IO error accured: {0}")]
+ IOError(String),
+ #[error("a Serde error accured: {0}")]
SerdeError(String),
+ #[error("an RustFmt error accured: {0}")]
FormatError(String),
+ #[error("the element tree contains no matching element")]
NonExistentElement,
+ #[error("the file dialog has been closed without selecting a valid option")]
DialogClosed,
+ #[error("{0}")]
String(String),
}
-impl std::fmt::Display for Error {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- match self {
- Self::SerdeError(string) | Self::FormatError(string) | Self::String(string) => {
- write!(f, "{}", string)
- }
- Self::IOError(kind) => {
- write!(f, "{}", kind)
- }
- Self::NonExistentElement => {
- write!(f, "The element tree contains no matching element.")
- }
- Self::DialogClosed => {
- write!(
- f,
- "The file dialog has been closed without selecting a valid option."
- )
- }
- }
- }
-}
-
impl From<std::io::Error> for Error {
fn from(value: std::io::Error) -> Self {
- Self::IOError(value.kind())
+ Self::IOError(value.to_string())
}
}
@@ -87,5 +74,6 @@ pub enum Message {
OpenFile,
FileOpened(Result<(PathBuf, Project), Error>),
SaveFile,
+ SaveFileAs,
FileSaved(Result<PathBuf, Error>),
}