Struct MarshalObject

Source
pub struct MarshalObject { /* private fields */ }
Expand description

Parsed contents of a pyc file or “marshal dump”

This data structure contains additional information about which objects are referenced by reference objects. This data can be used to clean up unused reference flags, which are, in general, not reproducible.

Implementations§

Source§

impl MarshalObject

Source

pub fn parse_pyc(data: &[u8]) -> Result<Self, Error>

Parse pyc file contents (header + marshal dump) from data

Source

pub fn parse_dump( data: &[u8], (major, minor): (u16, u16), ) -> Result<Self, Error>

Parse marshal dump contents from data

Since plain “marshal dumps” do not contain a pyc file header, the version of Python that was used to create the data must be specified.

Source

pub fn clear_unused_ref_flags(self, data: &[u8]) -> Result<Cow<'_, [u8]>, Error>

Clear unused reference flags from objects

This method can be used to make pyc files more reproducible.

Reference flags are removed from objects that are never referenced, and remaining references are adjusted for the shuffled index numbers.

If no changes are made, data is returned without modifications in a Cow::Borrowed, otherwise a Cow::Owned with new file contents is returned.

Source

pub fn print_unused_ref_flags(&self)

Print objects with unused reference flags to stdout

Source

pub fn inner(&self) -> &Object

Obtain a reference to the inner Object

Source

pub fn into_inner(self) -> Object

Consume this MarshalObject to obtain the inner Object

Trait Implementations§

Source§

impl Debug for MarshalObject

Source§

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

Formats the value using the given formatter. Read more

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.