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"
1212description = " netlink packet types"
1313
1414[dependencies ]
15- anyhow = " 1.0.31"
1615byteorder = " 1.3.2"
17- netlink-packet-utils = " 0.6.0"
1816
1917[dev-dependencies ]
2018netlink-packet-route = " 0.13.0"
Original file line number Diff line number Diff line change @@ -267,6 +267,3 @@ pub use self::message::*;
267267
268268pub mod constants;
269269pub 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 {
4141 /// This method panics if the buffer is not big enough.
4242 fn serialize ( & self , buffer : & mut [ u8 ] ) ;
4343}
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