diff options
Diffstat (limited to 'azalea-buf/src/read.rs')
| -rwxr-xr-x | azalea-buf/src/read.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/azalea-buf/src/read.rs b/azalea-buf/src/read.rs index 324eab87..b1b95f4d 100755 --- a/azalea-buf/src/read.rs +++ b/azalea-buf/src/read.rs @@ -199,6 +199,11 @@ impl<T: AzaleaRead> AzaleaRead for Vec<T> { Ok(contents) } } +impl<T: AzaleaRead> AzaleaRead for Box<[T]> { + default fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { + Vec::<T>::azalea_read(buf).map(Vec::into_boxed_slice) + } +} impl<T: AzaleaRead> AzaleaReadLimited for Vec<T> { fn azalea_read_limited(buf: &mut Cursor<&[u8]>, limit: usize) -> Result<Self, BufReadError> { let length = u32::azalea_read_var(buf)? as usize; @@ -216,6 +221,11 @@ impl<T: AzaleaRead> AzaleaReadLimited for Vec<T> { Ok(contents) } } +impl<T: AzaleaRead> AzaleaReadLimited for Box<[T]> { + fn azalea_read_limited(buf: &mut Cursor<&[u8]>, limit: usize) -> Result<Self, BufReadError> { + Vec::<T>::azalea_read_limited(buf, limit).map(Vec::into_boxed_slice) + } +} impl<K: AzaleaRead + Send + Eq + Hash, V: AzaleaRead + Send> AzaleaRead for HashMap<K, V> { fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { @@ -297,6 +307,11 @@ impl<T: AzaleaReadVar> AzaleaReadVar for Vec<T> { Ok(contents) } } +impl<T: AzaleaReadVar> AzaleaReadVar for Box<[T]> { + fn azalea_read_var(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { + Vec::<T>::azalea_read_var(buf).map(Vec::into_boxed_slice) + } +} impl AzaleaRead for i64 { fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { |
