Skip to content

Commit

Permalink
chore: Deprecate BinaryPackage::entrypoint_bytes
Browse files Browse the repository at this point in the history
Redundant method
  • Loading branch information
theduke committed Jun 3, 2024
1 parent c19546e commit 2723a45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions lib/wasix/src/bin_factory/binary_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,23 +174,27 @@ impl BinaryPackage {
}

/// Resolve the entrypoint command name to a [`BinaryPackageCommand`].
fn get_entrypoint_cmd(&self) -> Option<&BinaryPackageCommand> {
pub fn get_entrypoint_command(&self) -> Option<&BinaryPackageCommand> {
self.entrypoint_cmd
.as_deref()
.and_then(|name| self.get_command(name))
}

/// Get the bytes for the entrypoint command.
#[deprecated(
note = "Use BinaryPackage::get_entrypoint_cmd instead",
since = "0.22.0"
)]
pub fn entrypoint_bytes(&self) -> Option<&[u8]> {
self.get_entrypoint_cmd().map(|entry| entry.atom())
self.get_entrypoint_command().map(|entry| entry.atom())
}

/// Get a hash for this binary package.
///
/// Usually the hash of the entrypoint.
pub fn hash(&self) -> ModuleHash {
*self.hash.get_or_init(|| {
if let Some(cmd) = self.get_entrypoint_cmd() {
if let Some(cmd) = self.get_entrypoint_command() {
cmd.hash
} else {
ModuleHash::xxhash(self.id.to_string())
Expand Down
4 changes: 2 additions & 2 deletions lib/wasix/src/bin_factory/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ pub async fn spawn_load_wasm<'a>(
) -> Result<&'a [u8], SpawnError> {
let wasm = if let Some(cmd) = binary.get_command(name) {
cmd.atom.as_ref()
} else if let Some(wasm) = binary.entrypoint_bytes() {
wasm
} else if let Some(cmd) = binary.get_entrypoint_command() {
&cmd.atom
} else {
tracing::error!(
command=name,
Expand Down

0 comments on commit 2723a45

Please sign in to comment.