Enum Content

Source
pub enum Content {
    Object(Value),
    Block(Vec<u8>),
}
Expand description

The content read from a stream.

Either an object or raw primitive data. Also used to represent class and object annotations for custom write methods

This is the top level type that clients will interact with. When Java code writes to a stream it can choose to write

  • objects, which will each be read into an instance of Object (containing its data)

  • primitives, which are written as bytes and returned as instances of Block (containing the data).

    The individual java primitives are not distinguished in the stream so that writing (short)1 twice and writing (int)65537 once result in the same stream being wrtten. For this reason, decoding the bytes read is left to the client code that hopefully knows what format to expect.

Variants§

§

Object(Value)

A deserialized Java Object

§

Block(Vec<u8>)

An array of raw data

Implementations§

Source§

impl Content

Source

pub fn value(&self) -> Option<&Value>

Get the value of the object represented by this instance

Or None if this content is not a value.

Source

pub fn data(&self) -> Option<&[u8]>

Get the raw block data represented by this instance

Or None if this content is not raw data.

Trait Implementations§

Source§

impl Debug for Content

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Content

Source§

fn eq(&self, other: &Content) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Content

Auto Trait Implementations§

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.