#[non_exhaustive]pub struct ExtractedPackage {
pub name: String,
pub python_path: PathBuf,
pub native_extensions: Vec<NativeExtension>,
pub has_native_extensions: bool,
/* private fields */
}Expand description
An extracted package ready for use in a sandbox.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringPackage name (e.g., “numpy”).
python_path: PathBufPath to the extracted Python files directory.
This should be mounted at /site-packages.
native_extensions: Vec<NativeExtension>Native extensions (.so files) with their dlopen paths. Empty for pure-Python packages.
has_native_extensions: boolWhether this package has native extensions.
Implementations§
Source§impl ExtractedPackage
impl ExtractedPackage
Sourcepub fn from_path(path: impl AsRef<Path>) -> Result<Self, Error>
pub fn from_path(path: impl AsRef<Path>) -> Result<Self, Error>
Extract a package from a file path.
The format is auto-detected from the file extension.
§Errors
Returns an error if:
- The format cannot be detected
- The archive cannot be read or extracted
Sourcepub fn from_bytes(
bytes: &[u8],
format: PackageFormat,
name_hint: impl Into<String>,
) -> Result<Self, Error>
pub fn from_bytes( bytes: &[u8], format: PackageFormat, name_hint: impl Into<String>, ) -> Result<Self, Error>
Extract a package from raw bytes.
The format is specified explicitly since it cannot be detected from bytes alone.
The name_hint is used for the package name if one cannot be detected from
the archive contents (e.g., “numpy” or “requests-2.31.0”).
§Example
ⓘ
use eryx::package::{ExtractedPackage, PackageFormat};
// Load from bytes (e.g., downloaded from a URL)
let bytes = download_package("https://example.com/numpy-wasi.tar.gz").await?;
let package = ExtractedPackage::from_bytes(&bytes, PackageFormat::TarGz, "numpy")?;§Errors
Returns an error if:
- The format is
Directory(directories cannot be loaded from bytes) - The archive cannot be read or extracted
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExtractedPackage
impl RefUnwindSafe for ExtractedPackage
impl Send for ExtractedPackage
impl Sync for ExtractedPackage
impl Unpin for ExtractedPackage
impl UnsafeUnpin for ExtractedPackage
impl UnwindSafe for ExtractedPackage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
Set the “status” flags for the
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more