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
impl MarshalObject
Sourcepub fn parse_pyc(data: &[u8]) -> Result<Self, Error>
pub fn parse_pyc(data: &[u8]) -> Result<Self, Error>
Parse pyc
file contents (header + marshal dump) from data
Sourcepub fn parse_dump(
data: &[u8],
(major, minor): (u16, u16),
) -> Result<Self, Error>
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.
Sourcepub fn clear_unused_ref_flags(self, data: &[u8]) -> Result<Cow<'_, [u8]>, Error>
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.
Sourcepub fn print_unused_ref_flags(&self)
pub fn print_unused_ref_flags(&self)
Print objects with unused reference flags to stdout
Sourcepub fn into_inner(self) -> Object
pub fn into_inner(self) -> Object
Consume this MarshalObject
to obtain the inner Object