Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Public key CLI args validation #199

Merged
merged 3 commits into from
Nov 18, 2021

Conversation

StuartHarris
Copy link
Contributor

@StuartHarris StuartHarris commented Nov 18, 2021

This PR partially implements #192

  • create a const generic tuple struct Id that can represent public keys with a const PREFIX
  • alias this as ServerId, with generic parameter 'N'
  • implement FromStr for parsing
  • hook into StructOpt to display error when input is invalid
  • add the other public key types (ModuleId and ServiceId, with 'M' and 'V' respectively)
  • a few tidy ups and clippy fixes

Signed-off-by: Stuart Harris <stuart.harris@red-badger.com>
Signed-off-by: Stuart Harris <stuart.harris@red-badger.com>
Signed-off-by: Stuart Harris <stuart.harris@red-badger.com>
#[derive(Clone, Debug, Display, PartialEq, From, Into, Serialize, Deserialize)]
pub struct Id<const PREFIX: char>(String);

impl<const PREFIX: char> FromStr for Id<PREFIX> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never seen this done like this before. This is very cool.

Copy link
Member

@brooksmtownsend brooksmtownsend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome, thanks @StuartHarris !

@brooksmtownsend brooksmtownsend merged commit a9f980c into wasmCloud:main Nov 18, 2021
StuartHarris added a commit to redbadger/wash that referenced this pull request Nov 19, 2021
* Add Id const generic type, and HostId

Signed-off-by: Stuart Harris <stuart.harris@red-badger.com>

* ServerId, ServiceId, ModuleId

Signed-off-by: Stuart Harris <stuart.harris@red-badger.com>

* tiny refactor

Signed-off-by: Stuart Harris <stuart.harris@red-badger.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants