Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subnet qol #59

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

subnet qol #59

wants to merge 3 commits into from

Conversation

michaeldjeffrey
Copy link
Contributor

Replaces Org DevaddrConstraint with DevaddrSubnet to print CIDR subnet.

{
  "org": {
    "oui": 1,
    "owner": "13tyMLKRFYURNBQqLSqNJg9k41maP1A7Bh8QYxR13oWv7EnFooc",
    "payer": "112qB3YaH5bZkCnKA5uRH7tBtGNv2Y5B4smv1jsmvGUzgKT71QpE",
    "delegate_keys": [
      "112qB3YaH5bZkCnKA5uRH7tBtGNv2Y5B4smv1jsmvGUzgKT71QpE"
    ],
    "locked": false
  },
  "net_id": "000024",
  "devaddr_constraints": [
    {
      "range": {
        "start_addr": "48000000",
        "end_addr": "480003FF"
      },
      "subnets": [
        "48000000/22"
      ]
    }
  ]
}

fs::create_dir_all(parent)?;

let do_write = |msg: String| -> Result<Msg> {
if let Some(parent) = args.out_file.parent() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn’t this be if let None why would you need to create all the directories in the supplied path if it already exists?

let constraints: Vec<DevaddrConstraint> = res
.devaddr_constraints
.into_iter()
.map(|d| d.into())
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you do this conversion to a subnet in a single map like with .map(|d| d.into::<DevAddrConstraint>().to_subnet() and avoid the second iteration?

@jeffgrunewald
Copy link
Contributor

Does the description need updated? It looks like the output is going to include a subnet cidr notation address within the constraints object but the code looks like it matches the title in that the entire constraints field is being replaced by a subnet object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants