稍稍清理一下
This commit is contained in:
parent
454b124e0d
commit
56468db169
@ -405,9 +405,7 @@ impl NbtReader<'_> {
|
|||||||
self.cursor += 2;
|
self.cursor += 2;
|
||||||
value
|
value
|
||||||
}
|
}
|
||||||
/// 安全的读取 i16 类型的数据
|
/// 安全的读取小端 i16 数据
|
||||||
///
|
|
||||||
/// 转换大小端(小端)
|
|
||||||
///
|
///
|
||||||
/// 会在超出长度时 panic
|
/// 会在超出长度时 panic
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -470,7 +468,7 @@ impl NbtReader<'_> {
|
|||||||
}
|
}
|
||||||
/// 安全的读取一个 Varlong
|
/// 安全的读取一个 Varlong
|
||||||
///
|
///
|
||||||
/// 他有大小端区别吗? (其实是小端)
|
/// 他有大小端区别吗? (其实是小端)
|
||||||
///
|
///
|
||||||
/// 会在超出长度时 panic
|
/// 会在超出长度时 panic
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -491,7 +489,7 @@ impl NbtReader<'_> {
|
|||||||
Ok(value)
|
Ok(value)
|
||||||
}
|
}
|
||||||
/// 安全的读取一个 zigzag 编码的 varint
|
/// 安全的读取一个 zigzag 编码的 varint
|
||||||
///
|
///
|
||||||
/// 会在超出长度时 panic
|
/// 会在超出长度时 panic
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn read_zigzag_var_i32(&mut self) -> NbtResult<i32> {
|
pub fn read_zigzag_var_i32(&mut self) -> NbtResult<i32> {
|
||||||
@ -499,7 +497,7 @@ impl NbtReader<'_> {
|
|||||||
Ok((value >> 1) ^ (-(value & 1)))
|
Ok((value >> 1) ^ (-(value & 1)))
|
||||||
}
|
}
|
||||||
/// 安全的读取一个 zigzag 编码的 varlong
|
/// 安全的读取一个 zigzag 编码的 varlong
|
||||||
///
|
///
|
||||||
/// 会在超出长度时 panic
|
/// 会在超出长度时 panic
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn read_zigzag_var_i64(&mut self) -> NbtResult<i64> {
|
pub fn read_zigzag_var_i64(&mut self) -> NbtResult<i64> {
|
||||||
@ -799,31 +797,4 @@ impl NbtReader<'_> {
|
|||||||
self.cursor += len;
|
self.cursor += len;
|
||||||
Ok(value.into_owned())
|
Ok(value.into_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// 读取一个 NBT byte array
|
|
||||||
// pub fn read_nbt_i8_array(&mut self) -> Vec<i8> {
|
|
||||||
// let len = self.read_be_i32() as usize;
|
|
||||||
// let value = unsafe { self.read_i8_array_unsafe(len) };
|
|
||||||
// value
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /// 读取一个 NBT int array
|
|
||||||
// pub fn read_nbt_i32_array(&mut self) -> Vec<i32> {
|
|
||||||
// let len = self.read_be_i32() as usize;
|
|
||||||
// let value = unsafe { self.read_i32_array_unsafe(len) };
|
|
||||||
// value
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /// 读取一个 NBT long array
|
|
||||||
// pub fn read_nbt_i64_array(&mut self) -> Vec<i64> {
|
|
||||||
// let len = self.read_be_i32() as usize;
|
|
||||||
// let value = unsafe { self.read_i64_array_unsafe(len) };
|
|
||||||
// value
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /// 读取一个 NBT string
|
|
||||||
// pub fn read_nbt_string(&mut self) -> NbtResult<String> {
|
|
||||||
// let len = self.read_be_u16() as usize;
|
|
||||||
// self.read_string(len)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ mod nbt {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn big_test() {
|
fn big_test() {
|
||||||
let data: [u8; 0x608] = [
|
let mut data: [u8; 0x608] = [
|
||||||
0x0A, 0x00, 0x05, 0x4C, 0x65, 0x76, 0x65, 0x6C, 0x04, 0x00, 0x08, 0x6C, 0x6F, 0x6E,
|
0x0A, 0x00, 0x05, 0x4C, 0x65, 0x76, 0x65, 0x6C, 0x04, 0x00, 0x08, 0x6C, 0x6F, 0x6E,
|
||||||
0x67, 0x54, 0x65, 0x73, 0x74, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x02,
|
0x67, 0x54, 0x65, 0x73, 0x74, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x02,
|
||||||
0x00, 0x09, 0x73, 0x68, 0x6F, 0x72, 0x74, 0x54, 0x65, 0x73, 0x74, 0x7F, 0xFF, 0x08,
|
0x00, 0x09, 0x73, 0x68, 0x6F, 0x72, 0x74, 0x54, 0x65, 0x73, 0x74, 0x7F, 0xFF, 0x08,
|
||||||
@ -416,8 +416,9 @@ mod nbt {
|
|||||||
0x6F, 0x75, 0x62, 0x6C, 0x65, 0x54, 0x65, 0x73, 0x74, 0x3F, 0xDF, 0x8F, 0x6B, 0xBB,
|
0x6F, 0x75, 0x62, 0x6C, 0x65, 0x54, 0x65, 0x73, 0x74, 0x3F, 0xDF, 0x8F, 0x6B, 0xBB,
|
||||||
0xFF, 0x6A, 0x5E, 0x00,
|
0xFF, 0x6A, 0x5E, 0x00,
|
||||||
];
|
];
|
||||||
let value = NbtValue::from_binary::<nbt_version::Java>(&mut data.clone());
|
let value = NbtValue::from_binary::<nbt_version::Java>(&mut data);
|
||||||
println!("{:?}", value);
|
println!("{:?}", value);
|
||||||
|
assert!(value.is_ok());
|
||||||
// 其他版本
|
// 其他版本
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user