Actyx / Actyx

Local-First Cooperation based on Event Sourcing

Home Page:https://developer.actyx.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Move Default Paths to Proper Files

Kelerchian opened this issue · comments

I forgot to reply. I don't think addressing this right now is pertinent, though I agree. Both this and the previous issue you outlined are relevant but a bit outside the scope of this PR. Should we open an issue?

Originally posted by @jmg-duarte in #615 (comment)

The function in question is used in two places:

fn default_user_identity_dir() -> ActyxOSResult<PathBuf> {
let p = get_data_dir()?;
Ok(p.join("keys").join("users"))
}

pub fn load_dev_cert(path: Option<PathBuf>) -> ActyxOSResult<DeveloperCertificate> {
let path = path
.ok_or(())
.or_else(|_| ActyxOSResult::Ok(get_data_dir()?.join("certs").join("default")))?;
let s = fs::read_to_string(path.as_path()).ax_err_ctx(
ActyxOSCode::ERR_IO,
format!("failed to read developer certificate at {}", path.display()),
)?;
serde_json::from_str(&s).ax_err_ctx(ActyxOSCode::ERR_INVALID_INPUT, "reading developer certificate")
}

As you can see, both are placed in the same file.

Although, the first one is only used inside that file and the second one is only used outside the file. In ax to be precise.

I'm open to ideas, but the way this is used right now seems sensible to me, as it is done for OS defaults only.

as it is done for OS defaults only.

By this, do you mean that we are sure that these functions will be called only on certain platforms so that we are safe?

If I remember correctly, this issue (and my initial comment) stems from the idea that MAYBE it ax_core could be slowly made into a no_std lib and therefore these default paths should move to ax rather than ax_core.
But I'm not sure if it makes sense, making it no_std in the first place