DataDescription

Struct DataDescription 

Source
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: String

The memory location of this data, as a hex string prefaced with 0x

§type_string: String

The fully qualified type of this data

§value: Option<Value>

The value of this data

This may be:

  1. some owned data, such as a primitive or an enum value, which will be rendered as a string.
  2. some referenced data, which will be rendered as an arrow pointing to the referenced data.
  3. 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

Source

pub fn with_label<T>(self, label_string: T) -> Self
where T: Into<String>,

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?
examples/my_struct_manual.rs (line 21)
19    fn associated_data(&self) -> Option<Vec<DataDescription>> {
20        Some(vec![
21            DataDescription::from(&self.my_u8).with_label("my_u8"),
22            DataDescription::from(&self.my_string).with_label("my_string"),
23            DataDescription::from(&self.my_ref).with_label("my_ref"),
24        ])
25    }
More examples
Hide additional examples
examples/my_enum_manual.rs (line 38)
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    }
Source

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.

Source

pub fn render_table_row(&self) -> String

Create the HTML table row for this data

Trait Implementations§

Source§

impl Clone for DataDescription

Source§

fn clone(&self) -> DataDescription

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DataDescription

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DataDescription

Source§

fn default() -> DataDescription

Returns the “default value” for a type. Read more
Source§

impl<T> From<&T> for DataDescription
where T: Visualize,

Source§

fn from(t: &T) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.