aboutsummaryrefslogtreecommitdiff
path: root/azalea-core/src/resource_location.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-06-23 19:17:04 -0500
committermat <github@matdoes.dev>2022-06-23 19:17:04 -0500
commit37c6618c16319a7f40fd2e165190407472598e84 (patch)
tree6d712df8893041f0e49cfa6ca7adc9a411d39b84 /azalea-core/src/resource_location.rs
parent1089aa7961bd9af67c94dec9c5dbc6bd9f275225 (diff)
downloadazalea-drasl-37c6618c16319a7f40fd2e165190407472598e84.tar.xz
Fix everything so azalea-buf works
Diffstat (limited to 'azalea-core/src/resource_location.rs')
-rwxr-xr-xazalea-core/src/resource_location.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/azalea-core/src/resource_location.rs b/azalea-core/src/resource_location.rs
index 6807714b..61ae8a20 100755
--- a/azalea-core/src/resource_location.rs
+++ b/azalea-core/src/resource_location.rs
@@ -1,5 +1,8 @@
//! A resource, like minecraft:stone
+use azalea_buf::{McBufReadable, McBufWritable};
+use std::io::{Read, Write};
+
#[derive(Hash, Clone, PartialEq, Eq)]
pub struct ResourceLocation {
pub namespace: String,
@@ -44,18 +47,20 @@ impl std::fmt::Debug for ResourceLocation {
impl McBufReadable for ResourceLocation {
fn read_into(buf: &mut impl Read) -> Result<Self, String> {
- let location_string = self.read_utf()?;
+ let location_string = String::read_into(buf)?;
ResourceLocation::new(&location_string)
}
}
impl McBufWritable for ResourceLocation {
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
- buf.write_utf(&self.to_string())
+ self.to_string().write_into(buf)
}
}
#[cfg(test)]
mod tests {
+ use std::io::Cursor;
+
use super::*;
#[test]
@@ -86,13 +91,14 @@ mod tests {
#[test]
fn mcbuf_resource_location() {
let mut buf = Vec::new();
- buf.write_resource_location(&ResourceLocation::new("minecraft:dirt").unwrap())
- .unwrap();
+ ResourceLocation::new("minecraft:dirt")
+ .unwrap()
+ .write_into(&mut buf)?;
let mut buf = Cursor::new(buf);
assert_eq!(
- buf.read_resource_location().unwrap(),
+ ResourceLocation::read_into(&mut buf).unwrap(),
ResourceLocation::new("minecraft:dirt").unwrap()
);
}