zvariant_utils/signature/
child.rs1use std::ops::Deref;
2
3use super::Signature;
4
5#[derive(Debug, Clone)]
7pub enum Child {
8 Static { child: &'static Signature },
10 Dynamic { child: Box<Signature> },
12}
13static_assertions::assert_impl_all!(Child: Send, Sync, Unpin);
14
15impl Child {
16 pub const fn signature(&self) -> &Signature {
18 match self {
19 Child::Static { child } => child,
20 Child::Dynamic { child } => child,
21 }
22 }
23
24 pub const fn string_len(&self) -> usize {
26 self.signature().string_len()
27 }
28}
29
30impl Deref for Child {
31 type Target = Signature;
32
33 fn deref(&self) -> &Self::Target {
34 self.signature()
35 }
36}
37
38impl From<Box<Signature>> for Child {
39 fn from(child: Box<Signature>) -> Self {
40 Child::Dynamic { child }
41 }
42}
43
44impl From<Signature> for Child {
45 fn from(child: Signature) -> Self {
46 Child::Dynamic {
47 child: Box::new(child),
48 }
49 }
50}
51
52impl From<&'static Signature> for Child {
53 fn from(child: &'static Signature) -> Self {
54 Child::Static { child }
55 }
56}