Skip to content

Commit

Permalink
Added serialization attr for default stuff and some constructor helpe…
Browse files Browse the repository at this point in the history
…rs when creating nodes (#134)
  • Loading branch information
patrik-cihal authored Nov 23, 2023
1 parent 6aab253 commit cd76c33
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/draw/default_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::{draw::DrawContext, elements::EdgeProps, DisplayNode, Node};

use super::DisplayEdge;

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug)]
pub struct DefaultEdgeShape {
pub order: usize,
Expand Down
1 change: 1 addition & 0 deletions src/draw/default_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use super::DisplayNode;
/// This is the default node shape which is used to display nodes in the graph.
///
/// You can use this implementation as an example for implementing your own custom node shapes.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug)]
pub struct DefaultNodeShape {
pub pos: Pos2,
Expand Down
5 changes: 5 additions & 0 deletions src/elements/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,9 @@ where
pub fn set_label(&mut self, label: String) {
self.props.label = label
}

pub fn with_label(mut self, label: String) -> Self {
self.props.label = label;
self
}
}

0 comments on commit cd76c33

Please sign in to comment.