pub struct Resource<'a, X: 'a>{Show 28 fields
pub name: Cow<'a, str>,
pub is_python_module: bool,
pub is_python_builtin_extension_module: bool,
pub is_python_frozen_module: bool,
pub is_python_extension_module: bool,
pub is_shared_library: bool,
pub is_utf8_filename_data: bool,
pub is_python_package: bool,
pub is_python_namespace_package: bool,
pub in_memory_source: Option<Cow<'a, [X]>>,
pub in_memory_bytecode: Option<Cow<'a, [X]>>,
pub in_memory_bytecode_opt1: Option<Cow<'a, [X]>>,
pub in_memory_bytecode_opt2: Option<Cow<'a, [X]>>,
pub in_memory_extension_module_shared_library: Option<Cow<'a, [X]>>,
pub in_memory_package_resources: Option<HashMap<Cow<'a, str>, Cow<'a, [X]>>>,
pub in_memory_distribution_resources: Option<HashMap<Cow<'a, str>, Cow<'a, [X]>>>,
pub in_memory_shared_library: Option<Cow<'a, [X]>>,
pub shared_library_dependency_names: Option<Vec<Cow<'a, str>>>,
pub relative_path_module_source: Option<Cow<'a, Path>>,
pub relative_path_module_bytecode: Option<Cow<'a, Path>>,
pub relative_path_module_bytecode_opt1: Option<Cow<'a, Path>>,
pub relative_path_module_bytecode_opt2: Option<Cow<'a, Path>>,
pub relative_path_extension_module_shared_library: Option<Cow<'a, Path>>,
pub relative_path_package_resources: Option<HashMap<Cow<'a, str>, Cow<'a, Path>>>,
pub relative_path_distribution_resources: Option<HashMap<Cow<'a, str>, Cow<'a, Path>>>,
pub file_executable: bool,
pub file_data_embedded: Option<Cow<'a, [X]>>,
pub file_data_utf8_relative_path: Option<Cow<'a, str>>,
}
Expand description
Represents an indexed resource.
The resource has a name and type affinity via various is_*
fields.
The data for the resource may be present in the instance or referenced via an external filesystem path.
Data fields are Cow<T>
and can either hold a borrowed reference or
owned data. This allows the use of a single type to both hold
data or reference it from some other location.
Fields§
§name: Cow<'a, str>
The resource name.
is_python_module: bool
Whether this resource defines a Python module/package.
is_python_builtin_extension_module: bool
Whether this resource defines a builtin extension module.
is_python_frozen_module: bool
Whether this resource defines a frozen Python module.
is_python_extension_module: bool
Whether this resource defines a Python extension module.
Whether this resource defines a shared library.
is_utf8_filename_data: bool
Whether this resource defines data for an arbitrary file.
If set, name
is the UTF-8 encoded filename being represented.
The file data should exist in one of the file_data_*
fields.
is_python_package: bool
Whether the Python module is a package.
is_python_namespace_package: bool
Whether the Python module is a namespace package.
in_memory_source: Option<Cow<'a, [X]>>
Python module source code to use to import module from memory.
in_memory_bytecode: Option<Cow<'a, [X]>>
Python module bytecode to use to import module from memory.
in_memory_bytecode_opt1: Option<Cow<'a, [X]>>
Python module bytecode at optimized level 1 to use to import from memory.
in_memory_bytecode_opt2: Option<Cow<'a, [X]>>
Python module bytecode at optimized level 2 to use to import from memory.
Native machine code constituting a shared library for an extension module which can be imported from memory. (Not supported on all platforms.)
in_memory_package_resources: Option<HashMap<Cow<'a, str>, Cow<'a, [X]>>>
Mapping of virtual filename to data for resources to expose to Python’s
importlib.resources
API via in-memory data access.
in_memory_distribution_resources: Option<HashMap<Cow<'a, str>, Cow<'a, [X]>>>
Mapping of virtual filename to data for package distribution metadata
to expose to Python’s importlib.metadata
API via in-memory data access.
Native machine code constituting a shared library which can be imported from memory.
In-memory loading of shared libraries is not supported on all platforms.
Sequence of names of shared libraries this resource depends on.
relative_path_module_source: Option<Cow<'a, Path>>
Relative path to file containing Python module source code.
relative_path_module_bytecode: Option<Cow<'a, Path>>
Relative path to file containing Python module bytecode.
relative_path_module_bytecode_opt1: Option<Cow<'a, Path>>
Relative path to file containing Python module bytecode at optimization level 1.
relative_path_module_bytecode_opt2: Option<Cow<'a, Path>>
Relative path to file containing Python module bytecode at optimization level 2.
Relative path to file containing Python extension module loadable as a shared library.
relative_path_package_resources: Option<HashMap<Cow<'a, str>, Cow<'a, Path>>>
Mapping of Python package resource names to relative filesystem paths for those resources.
relative_path_distribution_resources: Option<HashMap<Cow<'a, str>, Cow<'a, Path>>>
Mapping of Python package distribution files to relative filesystem paths for those resources.
file_executable: bool
Whether this resource’s file data should be executable.
file_data_embedded: Option<Cow<'a, [X]>>
Holds arbitrary file data in memory.
file_data_utf8_relative_path: Option<Cow<'a, str>>
Holds arbitrary file data in a relative path encoded in UTF-8.
Implementations§
Source§impl<'a, X: Clone + 'a> Resource<'a, X>
impl<'a, X: Clone + 'a> Resource<'a, X>
Sourcepub fn is_meaningful(&self) -> bool
pub fn is_meaningful(&self) -> bool
Whether the resource is meaningful.
The resource is meaningful if it has data attached or is a package.
Sourcepub fn index_v1_length(&self) -> usize
pub fn index_v1_length(&self) -> usize
Compute length of index entry for version 1 payload format.
Sourcepub fn field_blob_length(&self, field: ResourceField) -> usize
pub fn field_blob_length(&self, field: ResourceField) -> usize
Compute the length of a field.
Interior padding is not part of the returned length.
Sourcepub fn field_blob_interior_padding_length(
&self,
field: ResourceField,
padding: BlobInteriorPadding,
) -> usize
pub fn field_blob_interior_padding_length( &self, field: ResourceField, padding: BlobInteriorPadding, ) -> usize
Compute the size of interior padding for a specific field.