| 1 |
use crate::errors::Result; |
| 2 |
use crate::fsshttpb::data::compact_u64::CompactU64; |
| 3 |
use crate::Reader; |
| 4 |
|
| 5 |
/// A byte array with the length determined by a `CompactU64`. |
| 6 |
/// |
| 7 |
/// See [\[MS-FSSHTTPB\] 2.2.1.3]. |
| 8 |
/// |
| 9 |
/// [\[MS-FSSHTTPB\] 2.2.1.3]: https://docs.microsoft.com/en-us/openspecs/sharepoint_protocols/ms-fsshttpb/6bdda105-af7f-4757-8dbe-0c7f3100647e |
| 10 |
pub(crate) struct BinaryItem(Vec<u8>); |
| 11 |
|
| 12 |
impl BinaryItem { |
| 13 |
pub(crate) fn parse(reader: Reader) -> Result<BinaryItem> { |
| 14 |
let size = CompactU64::parse(reader)?.value(); |
| 15 |
let data = reader.read(size as usize)?.to_vec(); |
| 16 |
|
| 17 |
Ok(BinaryItem(data)) |
| 18 |
} |
| 19 |
|
| 20 |
pub(crate) fn value(self) -> Vec<u8> { |
| 21 |
self.0 |
| 22 |
} |
| 23 |
} |