raw
1use url::Url;
2
3use crate::{
4 NodeId, PixelCoordinate, PixelDimension,
5 color::Color,
6 node::{GenericNode, GenericNodeInfo},
7};
8
9#[derive(
11 Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize, serde::Deserialize,
12)]
13pub struct LinkNode {
14 #[serde(flatten)]
15 generic: GenericNode,
16 url: Url,
17}
18
19impl LinkNode {
20 #[must_use]
22 pub const fn new(
23 id: NodeId,
24 x: PixelCoordinate,
25 y: PixelCoordinate,
26 width: PixelDimension,
27 height: PixelDimension,
28 color: Option<Color>,
29 url: Url,
30 ) -> Self {
31 Self {
32 generic: GenericNode::new(id, x, y, width, height, color),
33 url,
34 }
35 }
36
37 #[must_use]
39 pub const fn url(&self) -> &Url {
40 &self.url
41 }
42}
43
44impl GenericNodeInfo for LinkNode {
45 fn id(&self) -> &NodeId {
46 self.generic.id()
47 }
48
49 fn x(&self) -> PixelCoordinate {
50 self.generic.x()
51 }
52
53 fn y(&self) -> PixelCoordinate {
54 self.generic.y()
55 }
56
57 fn width(&self) -> PixelDimension {
58 self.generic.width()
59 }
60
61 fn height(&self) -> PixelDimension {
62 self.generic.height()
63 }
64
65 fn color(&self) -> &Option<Color> {
66 self.generic.color()
67 }
68}
69