aboutsummaryrefslogtreecommitdiff
path: root/games/rstnode/rst-client/src/error.rs
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2021-02-07 16:44:44 +0100
committerKatharina Fey <kookie@spacekookie.de>2021-02-07 16:44:44 +0100
commit79c8b9ab441493e3b3a37a59263f66896c9c90b3 (patch)
treeca111686fa202369a5730ff8151480b04e391cbb /games/rstnode/rst-client/src/error.rs
parentf5b36ff6b99256030201c878608a07d163b4c802 (diff)
rstnode: basic asset loading and prototype sprite rendering
* restructure assets directory * implement asset loading and dynamic conversion to sprites * reload sprites with unique URIs to load at runtime * provide an updated renderer API to give access to client state * use new APIs to draw a single node frame on screen * use colour APIs to dynamically change node frame colour
Diffstat (limited to 'games/rstnode/rst-client/src/error.rs')
-rw-r--r--games/rstnode/rst-client/src/error.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/games/rstnode/rst-client/src/error.rs b/games/rstnode/rst-client/src/error.rs
new file mode 100644
index 000000000000..08266bd5e591
--- /dev/null
+++ b/games/rstnode/rst-client/src/error.rs
@@ -0,0 +1,24 @@
+//! Various errors that can occur
+
+use std::{
+ error::Error,
+ fmt::{self, Display, Formatter},
+};
+
+/// Error loading an asset
+#[derive(Clone, Debug)]
+pub struct LoadError(String);
+
+impl<'s> From<&'s str> for LoadError {
+ fn from(s: &'s str) -> Self {
+ Self(s.into())
+ }
+}
+
+impl Display for LoadError {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ write!(f, "{}", self.0)
+ }
+}
+
+impl Error for LoadError {}