-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update stype (added envvars related types)
- Loading branch information
1 parent
3a30ee9
commit 285b82c
Showing
19 changed files
with
139 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
17 changes: 6 additions & 11 deletions
17
application/apps/indexer/session/src/unbound/commands/shells.rs
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 |
---|---|---|
@@ -1,30 +1,25 @@ | ||
use crate::unbound::signal::Signal; | ||
use envvars; | ||
use serde_json; | ||
|
||
pub fn get_valid_profiles( | ||
_signal: Signal, | ||
) -> Result<stypes::CommandOutcome<String>, stypes::ComputationError> { | ||
) -> Result<stypes::CommandOutcome<stypes::ProfileList>, stypes::ComputationError> { | ||
let mut profiles = envvars::get_profiles() | ||
.map_err(|e| stypes::ComputationError::IoOperation(e.to_string()))?; | ||
for profile in &mut profiles { | ||
if let Err(e) = profile.load() { | ||
log::warn!("Fail to load envvars for \"{}\": {e}", profile.name); | ||
} | ||
} | ||
Ok(stypes::CommandOutcome::Finished( | ||
serde_json::to_string(&profiles) | ||
.map_err(|e| stypes::ComputationError::IoOperation(e.to_string()))?, | ||
)) | ||
Ok(stypes::CommandOutcome::Finished(stypes::ProfileList( | ||
profiles.into_iter().map(|p| p.into()).collect(), | ||
))) | ||
} | ||
|
||
pub fn get_context_envvars( | ||
_signal: Signal, | ||
) -> Result<stypes::CommandOutcome<String>, stypes::ComputationError> { | ||
) -> Result<stypes::CommandOutcome<stypes::MapKeyValue>, stypes::ComputationError> { | ||
let envvars = envvars::get_context_envvars() | ||
.map_err(|e| stypes::ComputationError::IoOperation(e.to_string()))?; | ||
Ok(stypes::CommandOutcome::Finished( | ||
serde_json::to_string(&envvars) | ||
.map_err(|e| stypes::ComputationError::IoOperation(e.to_string()))?, | ||
)) | ||
Ok(stypes::CommandOutcome::Finished(envvars.into())) | ||
} |
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
13 changes: 13 additions & 0 deletions
13
application/apps/indexer/stypes/src/command/profiles/converting.rs
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,13 @@ | ||
use crate::*; | ||
|
||
/// Converts a `envvars::Profile` into an `Profile`. | ||
impl From<envvars::Profile> for Profile { | ||
fn from(pro: envvars::Profile) -> Self { | ||
Profile { | ||
name: pro.name, | ||
path: pro.path, | ||
envvars: pro.envvars, | ||
symlink: pro.symlink, | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
application/apps/indexer/stypes/src/command/profiles/mod.rs
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,32 @@ | ||
#[cfg(feature = "rustcore")] | ||
mod converting; | ||
|
||
use crate::*; | ||
|
||
#[derive(Clone, Serialize, Deserialize, Debug)] | ||
#[extend::encode_decode] | ||
#[cfg_attr(test, derive(TS), ts(export, export_to = "command.ts"))] | ||
pub struct Profile { | ||
/// Suggested name of shell. For unix based systems it will be name of executable file, | ||
/// like "bash", "fish" etc. For windows it will be names like "GitBash", "PowerShell" | ||
/// etc. | ||
pub name: String, | ||
/// Path to executable file of shell | ||
pub path: PathBuf, | ||
/// List of environment variables. Because extracting operation could take some time | ||
/// by default `envvars = None`. To load data should be used method `load`, which will | ||
/// make attempt to detect environment variables. | ||
#[cfg_attr(test, ts(type = "Map<string, string>"))] | ||
pub envvars: Option<HashMap<String, String>>, | ||
/// true - if path to executable file of shell is symlink to another location. | ||
pub symlink: bool, | ||
} | ||
|
||
/// Represents a list of serial ports. | ||
/// | ||
/// This structure contains a vector of strings, where each string represents the name | ||
/// or identifier of a serial port available on the system. | ||
#[derive(Clone, Serialize, Deserialize, Debug)] | ||
#[extend::encode_decode] | ||
#[cfg_attr(test, derive(TS), ts(export, export_to = "command.ts"))] | ||
pub struct ProfileList(pub Vec<Profile>); |
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
6 changes: 6 additions & 0 deletions
6
application/apps/indexer/stypes/src/miscellaneous/converting.rs
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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