-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(crypto-helper): asn1: implement Set rendering;
- Loading branch information
1 parent
da575d3
commit 810c6dc
Showing
5 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use asn1_parser::{OwnedRawAsn1EntityData, OwnedSet}; | ||
use yew::{function_component, html, Callback, Html, Properties}; | ||
|
||
use crate::asn1::node_options::NodeOptions; | ||
use crate::asn1::scheme::build_asn1_schema; | ||
use crate::asn1::HighlightAction; | ||
|
||
#[derive(PartialEq, Properties, Clone)] | ||
pub struct SetNodeProps { | ||
pub node: OwnedSet, | ||
pub cur_node: Option<u64>, | ||
pub set_cur_node: Callback<HighlightAction>, | ||
pub meta: OwnedRawAsn1EntityData, | ||
} | ||
|
||
#[function_component(SetNode)] | ||
pub fn set(props: &SetNodeProps) -> Html { | ||
let fields = props.node.fields(); | ||
|
||
let set_cur_node = &props.set_cur_node; | ||
let fields_components = fields | ||
.iter() | ||
.map(|f| build_asn1_schema(f, &props.cur_node, set_cur_node)) | ||
.collect::<Vec<_>>(); | ||
|
||
let offset = props.meta.tag_position(); | ||
let length_len = props.meta.length_range().len(); | ||
let data_len = props.meta.data_range().len(); | ||
|
||
html! { | ||
<div style="cursor: crosshair; width: 100%"> | ||
<div class="asn1-constructor-header"> | ||
<NodeOptions node_bytes={props.meta.raw_bytes().to_vec()} {offset} {length_len} {data_len} name={String::from("Set")}/> | ||
<span class="asn1-node-info-label">{format!("({} fields)", fields.len())}</span> | ||
</div> | ||
<div class="asn1-constructor-body"> | ||
{fields_components} | ||
</div> | ||
</div> | ||
} | ||
} |