Rebrand to Galaxy, major improvements to Bedrock support, still needs some TLC though
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
use std::{
|
||||
io,
|
||||
path::PathBuf,
|
||||
sync::atomic::{AtomicUsize, Ordering},
|
||||
};
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum FileSaveError {
|
||||
#[error("No file path associated with file when saving file {0:?}")]
|
||||
NoFilePath(FileId),
|
||||
#[error("IO error when saving file.")]
|
||||
IOError {
|
||||
#[source]
|
||||
error: io::Error,
|
||||
path: PathBuf,
|
||||
},
|
||||
#[error("Remote file operation failed: {0}")]
|
||||
RemoteError(String),
|
||||
}
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum FileLoadError {
|
||||
#[error("File does not exist")]
|
||||
DoesNotExist,
|
||||
#[error("IO error when loading file.")]
|
||||
IOError(#[from] io::Error),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct FileId(usize);
|
||||
|
||||
impl FileId {
|
||||
/// Constructs a new globally-unique file ID.
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> FileId {
|
||||
static NEXT_ID: AtomicUsize = AtomicUsize::new(0);
|
||||
let raw = NEXT_ID.fetch_add(1, Ordering::Relaxed);
|
||||
FileId(raw)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user