This repository has been archived by the owner on Jul 17, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal: Migrate to proto v0.21 version types. (#13)
- Loading branch information
Showing
8 changed files
with
154 additions
and
141 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use extism_pdk::*; | ||
use proto_pdk::*; | ||
use std::path::PathBuf; | ||
|
||
#[host_fn] | ||
extern "ExtismHost" { | ||
fn get_env_var(name: &str) -> String; | ||
} | ||
|
||
pub fn get_rustup_home(env: &HostEnvironment) -> Result<PathBuf, Error> { | ||
// Variable returns a real path | ||
Ok(host_env!("RUSTUP_HOME") | ||
.map(PathBuf::from) | ||
// So we need our fallback to also be a real path | ||
.unwrap_or_else(|| env.home_dir.real_path().join(".rustup"))) | ||
} | ||
|
||
pub fn get_channel_from_version(spec: &VersionSpec) -> String { | ||
if spec.is_canary() { | ||
"nightly".to_owned() | ||
} else { | ||
spec.to_string() | ||
} | ||
} | ||
|
||
pub fn is_non_version_channel(spec: &UnresolvedVersionSpec) -> bool { | ||
match spec { | ||
UnresolvedVersionSpec::Canary => true, | ||
UnresolvedVersionSpec::Alias(value) => { | ||
value == "stable" | ||
|| value == "beta" | ||
|| value == "nightly" | ||
|| value.starts_with("nightly") | ||
} | ||
_ => false, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters