aboutsummaryrefslogtreecommitdiff
path: root/azalea-nbt/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-05-09 22:05:46 -0500
committermat <git@matdoes.dev>2023-05-09 22:05:46 -0500
commite1e1063d15a97bf93ec6dd1a082f78b0c3191d1d (patch)
tree766e690f5c2b7e81ebfddf4d2ce887afc7e4e889 /azalea-nbt/src
parent53d51a5ca92aa8ddea9d82b6b44ac7aaa06c2095 (diff)
downloadazalea-drasl-e1e1063d15a97bf93ec6dd1a082f78b0c3191d1d.tar.xz
astar
Diffstat (limited to 'azalea-nbt/src')
-rw-r--r--azalea-nbt/src/serde/mod.rs1
-rw-r--r--azalea-nbt/src/serde/serializer.rs205
2 files changed, 206 insertions, 0 deletions
diff --git a/azalea-nbt/src/serde/mod.rs b/azalea-nbt/src/serde/mod.rs
new file mode 100644
index 00000000..21d53a0f
--- /dev/null
+++ b/azalea-nbt/src/serde/mod.rs
@@ -0,0 +1 @@
+mod serializer;
diff --git a/azalea-nbt/src/serde/serializer.rs b/azalea-nbt/src/serde/serializer.rs
new file mode 100644
index 00000000..945d2b42
--- /dev/null
+++ b/azalea-nbt/src/serde/serializer.rs
@@ -0,0 +1,205 @@
+use serde::{ser, Serialize};
+
+use crate::Nbt;
+
+use std;
+use std::fmt::{self, Display};
+
+use serde::de;
+
+pub type Result<T> = std::result::Result<T, Error>;
+
+// This is a bare-bones implementation. A real library would provide additional
+// information in its error type, for example the line and column at which the
+// error occurred, the byte offset into the input, or the current key being
+// processed.
+#[derive(Debug)]
+pub enum Error {
+ Message(String),
+}
+
+impl Display for Error {
+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ match self {
+ Error::Message(msg) => formatter.write_str(msg),
+ }
+ }
+}
+
+impl ser::Error for Error {
+ fn custom<T: Display>(msg: T) -> Self {
+ Error::Message(msg.to_string())
+ }
+}
+
+impl de::Error for Error {
+ fn custom<T: Display>(msg: T) -> Self {
+ Error::Message(msg.to_string())
+ }
+}
+
+impl std::error::Error for Error {}
+
+impl<'a> ser::Serializer for &'a mut Nbt {
+ type Ok = ();
+
+ type Error = Error;
+
+ type SerializeSeq = Self;
+
+ type SerializeTuple = Self;
+
+ type SerializeTupleStruct = Self;
+
+ type SerializeTupleVariant = Self;
+
+ type SerializeMap = Self;
+
+ type SerializeStruct = Self;
+
+ type SerializeStructVariant = Self;
+
+ fn serialize_bool(self, v: bool) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_i8(self, v: i8) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_i16(self, v: i16) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_i32(self, v: i32) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_i64(self, v: i64) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_u8(self, v: u8) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_u16(self, v: u16) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_u32(self, v: u32) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_u64(self, v: u64) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_f32(self, v: f32) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_f64(self, v: f64) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_char(self, v: char) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_str(self, v: &str) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_bytes(self, v: &[u8]) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_none(self) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_some<T: ?Sized>(self, value: &T) -> Result<()>
+ where
+ T: Serialize,
+ {
+ todo!()
+ }
+
+ fn serialize_unit(self) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_unit_struct(self, name: &'static str) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_unit_variant(
+ self,
+ name: &'static str,
+ variant_index: u32,
+ variant: &'static str,
+ ) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_newtype_struct<T: ?Sized>(self, name: &'static str, value: &T) -> Result<()>
+ where
+ T: Serialize,
+ {
+ todo!()
+ }
+
+ fn serialize_newtype_variant<T: ?Sized>(
+ self,
+ name: &'static str,
+ variant_index: u32,
+ variant: &'static str,
+ value: &T,
+ ) -> Result<()>
+ where
+ T: Serialize,
+ {
+ todo!()
+ }
+
+ fn serialize_seq(self, len: Option<usize>) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_tuple(self, len: usize) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_tuple_struct(self, name: &'static str, len: usize) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_tuple_variant(
+ self,
+ name: &'static str,
+ variant_index: u32,
+ variant: &'static str,
+ len: usize,
+ ) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_map(self, len: Option<usize>) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_struct(self, name: &'static str, len: usize) -> Result<()> {
+ todo!()
+ }
+
+ fn serialize_struct_variant(
+ self,
+ name: &'static str,
+ variant_index: u32,
+ variant: &'static str,
+ len: usize,
+ ) -> Result<()> {
+ todo!()
+ }
+}