pub struct DataDescription {
pub label_string: Option<String>,
pub hex_address_string: String,
pub type_string: String,
pub value: Option<Value>,
pub associated_data_descriptions: Option<Vec<DataDescription>>,
}Expand description
The data needed to generate a graph node for a data structure
Fields§
§label_string: Option<String>The label for this piece of data
Typically this is the variable name or field name.
Leaving this field as None will result in no TD box rendered for this field.
hex_address_string: StringThe memory location of this data, as a hex string prefaced with 0x
type_string: StringThe fully qualified type of this data
value: Option<Value>The value of this data
This may be:
- some owned data, such as a primitive or an enum value, which will be rendered as a string.
- some referenced data, which will be rendered as an arrow pointing to the referenced data.
- nothing, as would make sense for a struct, where the real data is the fields, which are represented in DataDescription::associated_data_descriptions
associated_data_descriptions: Option<Vec<DataDescription>>The DataDescriptions owned by this data
These will be rendered as part of this data.
Implementations§
Source§impl DataDescription
impl DataDescription
Sourcepub fn with_label<T>(self, label_string: T) -> Self
pub fn with_label<T>(self, label_string: T) -> Self
Add a label to this node
Labels are generally optional but can be helpful for named structured data, like the fields of a struct. Labels are less likely to be used for tuple structs or tuple enums.
Examples found in repository?
More examples
30 fn associated_data(&self) -> Option<Vec<DataDescription>> {
31 match self {
32 MyEnum::Plain => None,
33 MyEnum::WithU8(a) => Some(vec![DataDescription::from(a)]),
34 MyEnum::WithU8AndString(a, b) => {
35 Some(vec![DataDescription::from(a), DataDescription::from(b)])
36 }
37 MyEnum::WithStruct { my_u8, my_string } => Some(vec![
38 DataDescription::from(my_u8).with_label("my_u8"),
39 DataDescription::from(my_string).with_label("my_string"),
40 ]),
41 }
42 }Sourcepub fn render_references(&self, node_name: &str) -> String
pub fn render_references(&self, node_name: &str) -> String
Create the DOT code to make all arrows from data owned by this node to the data they reference
The referenced nodes must be added to the graph separately.
Sourcepub fn render_table_row(&self) -> String
pub fn render_table_row(&self) -> String
Create the HTML table row for this data
Trait Implementations§
Source§impl Clone for DataDescription
impl Clone for DataDescription
Source§fn clone(&self) -> DataDescription
fn clone(&self) -> DataDescription
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more