pub struct JceParser<'de> { /* private fields */ }Expand description
Manually construct jce format
§Example
use serde_jce::{JceParser, JceType};
let mut parser = JceParser::from_bytes(&[0x00, 0x12, 0x11, 0x12, 0x34]);
assert_eq!(parser.pick_head(), Ok((0, JceType::I8)));
assert_eq!(parser.i8(), Ok(0x12));
assert_eq!(parser.pick_head(), Ok((1, JceType::I16)));
assert_eq!(parser.i16(), Ok(0x1234));
assert_eq!(parser.done(), true);§Error
When JceParser returns Error, remaining bytes will change due to incorrect parsing
This means, the parsing operation is not atomic
Implementations§
Source§impl<'de> JceParser<'de>
impl<'de> JceParser<'de>
pub fn i8(&mut self) -> Result<i8>
pub fn i16(&mut self) -> Result<i16>
pub fn i32(&mut self) -> Result<i32>
pub fn i64(&mut self) -> Result<i64>
pub fn f32(&mut self) -> Result<f32>
pub fn f64(&mut self) -> Result<f64>
pub fn str_small(&mut self) -> Result<&'de str>
pub fn str_big(&mut self) -> Result<&'de str>
pub fn str(&mut self) -> Result<&'de str>
Sourcepub fn struct_begin<'a>(&mut self) -> Result<()>
pub fn struct_begin<'a>(&mut self) -> Result<()>
Basically do nothing but swallow headers
Sourcepub fn struct_end<'a>(&mut self) -> Result<()>
pub fn struct_end<'a>(&mut self) -> Result<()>
Basically do nothing but swallow headers
pub fn zero(&mut self) -> Result<()>
pub fn bytes(&mut self) -> Result<&'de [u8]>
pub fn ignore(&mut self) -> Result<()>
Auto Trait Implementations§
impl<'de> Freeze for JceParser<'de>
impl<'de> RefUnwindSafe for JceParser<'de>
impl<'de> Send for JceParser<'de>
impl<'de> Sync for JceParser<'de>
impl<'de> Unpin for JceParser<'de>
impl<'de> UnwindSafe for JceParser<'de>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more