diff options
| author | mat <github@matdoes.dev> | 2022-01-02 17:07:01 -0600 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-01-02 17:07:01 -0600 |
| commit | bb566aa54131a23b6d9e605c81a8ff4d1d1c21d7 (patch) | |
| tree | 157b88ee64215516e27d9f765513d3aa4fef0d64 /azalea-protocol/src/mc_buf | |
| parent | bb57273f48294355d7ac863c291d80878f711c16 (diff) | |
| download | azalea-drasl-bb566aa54131a23b6d9e605c81a8ff4d1d1c21d7.tar.xz | |
implement for Vec<u8>
Diffstat (limited to 'azalea-protocol/src/mc_buf')
| -rw-r--r-- | azalea-protocol/src/mc_buf/read.rs | 10 | ||||
| -rw-r--r-- | azalea-protocol/src/mc_buf/write.rs | 6 |
2 files changed, 16 insertions, 0 deletions
diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs index c429eb7f..683c7d9a 100644 --- a/azalea-protocol/src/mc_buf/read.rs +++ b/azalea-protocol/src/mc_buf/read.rs @@ -228,3 +228,13 @@ impl McBufVarintReadable for i32 { buf.read_varint().await } } + +#[async_trait] +impl McBufReadable for Vec<u8> { + async fn read_into<R>(buf: &mut R) -> Result<Self, String> + where + R: AsyncRead + std::marker::Unpin + std::marker::Send, + { + buf.read_bytes().await + } +} diff --git a/azalea-protocol/src/mc_buf/write.rs b/azalea-protocol/src/mc_buf/write.rs index 3c3375b9..7b1ac861 100644 --- a/azalea-protocol/src/mc_buf/write.rs +++ b/azalea-protocol/src/mc_buf/write.rs @@ -178,3 +178,9 @@ impl McBufVarintWritable for i32 { buf.write_varint(*self) } } + +impl McBufWritable for Vec<u8> { + fn write_into(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { + buf.write_bytes(self) + } +} |
