Struct Parser

Source
pub struct Parser<T> { /* private fields */ }
Expand description

The main parser class

// Input can be anything that implements Read, eg file or tcp stream
let sample = File::open("sample").expect("Sample file missing");
// Stream is checked at creation to ensure stream is java serialization
let mut parser = Parser::new(sample)?;
// Objects are read from stream in turn
let obj = parser.read()?;
println!("Read Object: {:?}", obj);
println!("Class name: {}", obj.value().unwrap().object_data().unwrap().class_name());

Implementations§

Source§

impl<T: Read> Parser<T>

Source

pub fn new(source: T) -> Result<Self>

Create a parser to read Java objects from a serial stream

Source

pub fn read(&mut self) -> ReadResult<Content>

Read the next item from the Java stream

Source

pub fn read_as<S: FromJava>(&mut self) -> Result<S>

Read the next item from the stream and convert it to required type

Auto Trait Implementations§

§

impl<T> Freeze for Parser<T>

§

impl<T> RefUnwindSafe for Parser<T>
where T: RefUnwindSafe,

§

impl<T> Send for Parser<T>
where T: Send,

§

impl<T> Sync for Parser<T>
where T: Sync,

§

impl<T> Unpin for Parser<T>

§

impl<T> UnwindSafe for Parser<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.