File tree Expand file tree Collapse file tree 3 files changed +43
-5
lines changed Expand file tree Collapse file tree 3 files changed +43
-5
lines changed Original file line number Diff line number Diff line change @@ -12,9 +12,7 @@ repository = "https://github.com/rust-netlink/netlink-packet-core"
12
12
description = " netlink packet types"
13
13
14
14
[dependencies ]
15
- anyhow = " 1.0.31"
16
15
byteorder = " 1.3.2"
17
- netlink-packet-utils = " 0.6.0"
18
16
19
17
[dev-dependencies ]
20
18
netlink-packet-route = " 0.13.0"
Original file line number Diff line number Diff line change @@ -267,6 +267,3 @@ pub use self::message::*;
267
267
268
268
pub mod constants;
269
269
pub use self :: constants:: * ;
270
-
271
- pub ( crate ) use self :: utils:: traits:: * ;
272
- pub ( crate ) use netlink_packet_utils as utils;
Original file line number Diff line number Diff line change @@ -41,3 +41,46 @@ pub trait NetlinkSerializable {
41
41
/// This method panics if the buffer is not big enough.
42
42
fn serialize ( & self , buffer : & mut [ u8 ] ) ;
43
43
}
44
+
45
+ /// A type that implements `Emitable` can be serialized.
46
+ pub trait Emitable {
47
+ /// Return the length of the serialized data.
48
+ fn buffer_len ( & self ) -> usize ;
49
+
50
+ /// Serialize this types and write the serialized data into the given
51
+ /// buffer.
52
+ ///
53
+ /// # Panic
54
+ ///
55
+ /// This method panic if the buffer is not big enough. You **must** make
56
+ /// sure the buffer is big enough before calling this method. You can
57
+ /// use [`buffer_len()`](trait.Emitable.html#method.buffer_len) to check
58
+ /// how big the storage needs to be.
59
+ fn emit ( & self , buffer : & mut [ u8 ] ) ;
60
+ }
61
+
62
+ /// A `Parseable` type can be used to deserialize data from the type `T` for
63
+ /// which it is implemented.
64
+ pub trait Parseable < T >
65
+ where
66
+ Self : Sized ,
67
+ T : ?Sized ,
68
+ {
69
+ type Error ;
70
+
71
+ /// Deserialize the current type.
72
+ fn parse ( buf : & T ) -> Result < Self , Self :: Error > ;
73
+ }
74
+
75
+ /// A `Parseable` type can be used to deserialize data from the type `T` for
76
+ /// which it is implemented.
77
+ pub trait ParseableParametrized < T , P >
78
+ where
79
+ Self : Sized ,
80
+ T : ?Sized ,
81
+ {
82
+ type Error ;
83
+
84
+ /// Deserialize the current type.
85
+ fn parse_with_param ( buf : & T , params : P ) -> Result < Self , Self :: Error > ;
86
+ }
You can’t perform that action at this time.
0 commit comments