diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2022-10-07 20:12:36 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-07 20:12:36 -0500 |
| commit | bc3aa9467ae1e2d0ea1727093af9b0af14965e69 (patch) | |
| tree | 8db3b735daed484507129eb0683db88ddec14210 /azalea-buf/src/serializable_uuid.rs | |
| parent | 695efef66fdf1e08f0cb6d8783c085875100fa2d (diff) | |
| download | azalea-drasl-bc3aa9467ae1e2d0ea1727093af9b0af14965e69.tar.xz | |
Replace impl Read with Cursor<&[u8]> (#26)
* Start getting rid of Cursor
* try to make the tests pass and fail
* make the tests pass
* remove unused uses
* fix clippy warnings
* fix potential OOM exploits
* fix OOM in az-nbt
* fix nbt benchmark
* fix a test
* start replacing it with Cursor<Vec<u8>>
* wip
* fix all the issues
* fix all tests
* fix nbt benchmark
* fix warnings
Diffstat (limited to 'azalea-buf/src/serializable_uuid.rs')
| -rw-r--r-- | azalea-buf/src/serializable_uuid.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/azalea-buf/src/serializable_uuid.rs b/azalea-buf/src/serializable_uuid.rs index 66cdda73..dc251269 100644 --- a/azalea-buf/src/serializable_uuid.rs +++ b/azalea-buf/src/serializable_uuid.rs @@ -1,5 +1,5 @@ use crate::{read::BufReadError, McBufReadable, McBufWritable}; -use std::io::{Read, Write}; +use std::io::{Cursor, Write}; use uuid::Uuid; pub trait SerializableUuid { @@ -33,7 +33,7 @@ impl SerializableUuid for Uuid { } impl McBufReadable for Uuid { - fn read_from(buf: &mut impl Read) -> Result<Self, BufReadError> { + fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { Ok(Uuid::from_int_array([ u32::read_from(buf)?, u32::read_from(buf)?, @@ -80,7 +80,7 @@ mod tests { u.write_into(&mut buf).unwrap(); println!("{:?}", buf); assert_eq!(buf.len(), 16); - let u2 = Uuid::read_from(&mut buf.as_slice()).unwrap(); + let u2 = Uuid::read_from(&mut Cursor::new(&buf)).unwrap(); assert_eq!(u, u2); } } |
