Make LoadError Clone.

Fixes #11
This commit is contained in:
Ethiraric 2024-09-25 16:31:18 +02:00
parent 1fc46923ef
commit fd5a606b19

View file

@ -1,6 +1,6 @@
//! The default loader. //! The default loader.
use std::collections::BTreeMap; use std::{collections::BTreeMap, sync::Arc};
use hashlink::LinkedHashMap; use hashlink::LinkedHashMap;
use saphyr_parser::{Event, MarkedEventReceiver, Marker, ScanError, TScalarStyle, Tag}; use saphyr_parser::{Event, MarkedEventReceiver, Marker, ScanError, TScalarStyle, Tag};
@ -172,10 +172,10 @@ where
} }
/// An error that happened when loading a YAML document. /// An error that happened when loading a YAML document.
#[derive(Debug)] #[derive(Debug, Clone)]
pub enum LoadError { pub enum LoadError {
/// An I/O error. /// An I/O error.
IO(std::io::Error), IO(Arc<std::io::Error>),
/// An error within the scanner. This indicates a malformed YAML input. /// An error within the scanner. This indicates a malformed YAML input.
Scan(ScanError), Scan(ScanError),
/// A decoding error (e.g.: Invalid UTF-8). /// A decoding error (e.g.: Invalid UTF-8).
@ -184,7 +184,7 @@ pub enum LoadError {
impl From<std::io::Error> for LoadError { impl From<std::io::Error> for LoadError {
fn from(error: std::io::Error) -> Self { fn from(error: std::io::Error) -> Self {
LoadError::IO(error) LoadError::IO(Arc::new(error))
} }
} }