aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/mc_buf/read.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-01-02 17:19:04 -0600
committermat <github@matdoes.dev>2022-01-02 17:19:04 -0600
commit094c210dada7c0ee83c19965739312d2d00e4099 (patch)
tree00b678a2aa0c03bbfde12475431d749c0b2b837f /azalea-protocol/src/mc_buf/read.rs
parentbb566aa54131a23b6d9e605c81a8ff4d1d1c21d7 (diff)
downloadazalea-drasl-094c210dada7c0ee83c19965739312d2d00e4099.tar.xz
switch all current macro types to the new system
Diffstat (limited to 'azalea-protocol/src/mc_buf/read.rs')
-rw-r--r--azalea-protocol/src/mc_buf/read.rs66
1 files changed, 66 insertions, 0 deletions
diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs
index 683c7d9a..374e5443 100644
--- a/azalea-protocol/src/mc_buf/read.rs
+++ b/azalea-protocol/src/mc_buf/read.rs
@@ -238,3 +238,69 @@ impl McBufReadable for Vec<u8> {
buf.read_bytes().await
}
}
+
+// string
+#[async_trait]
+impl McBufReadable for String {
+ async fn read_into<R>(buf: &mut R) -> Result<Self, String>
+ where
+ R: AsyncRead + std::marker::Unpin + std::marker::Send,
+ {
+ buf.read_utf().await
+ }
+}
+
+// ResourceLocation
+#[async_trait]
+impl McBufReadable for ResourceLocation {
+ async fn read_into<R>(buf: &mut R) -> Result<Self, String>
+ where
+ R: AsyncRead + std::marker::Unpin + std::marker::Send,
+ {
+ buf.read_resource_location().await
+ }
+}
+
+// u32
+#[async_trait]
+impl McBufReadable for u32 {
+ async fn read_into<R>(buf: &mut R) -> Result<Self, String>
+ where
+ R: AsyncRead + std::marker::Unpin + std::marker::Send,
+ {
+ buf.read_int().await.map(|i| i as u32)
+ }
+}
+
+// u32 varint
+#[async_trait]
+impl McBufVarintReadable for u32 {
+ async fn varint_read_into<R>(buf: &mut R) -> Result<Self, String>
+ where
+ R: AsyncRead + std::marker::Unpin + std::marker::Send,
+ {
+ buf.read_varint().await.map(|i| i as u32)
+ }
+}
+
+// u16
+#[async_trait]
+impl McBufReadable for u16 {
+ async fn read_into<R>(buf: &mut R) -> Result<Self, String>
+ where
+ R: AsyncRead + std::marker::Unpin + std::marker::Send,
+ {
+ buf.read_short().await.map(|i| i as u16)
+ }
+}
+
+// u16 varint
+#[async_trait]
+impl McBufVarintReadable for u16 {
+ async fn varint_read_into<R>(buf: &mut R) -> Result<Self, String>
+ where
+ R: AsyncRead + std::marker::Unpin + std::marker::Send,
+ {
+ buf.read_varint().await.map(|i| i as u16)
+ }
+}