Debian Codegraph @

tests/run-pass/construct_with.rs

raw symbols SCIP
1 // Copyright (c) 2021 Pierre Chifflier <[email protected]>
2 //
3 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6 // option. This file may not be copied, modified, or distributed
7 // except according to those terms.
8
9 extern crate pnet_macros;
10 extern crate pnet_macros_support;
11 use pnet_macros::packet;
12 use pnet_macros_support::packet::PrimitiveValues;
13
14 #[derive(Clone, Copy, Debug)]
15 pub struct Toto{
16 dummy: u16,
17 }
18
19 impl PrimitiveValues for Toto {
20 type T = (u16,);
21 fn to_primitive_values(&self) -> (u16,) {
22 (self.dummy,)
23 }
24 }
25
26 impl Toto {
27 pub fn new(dummy: u16) -> Self {
28 Toto{ dummy }
29 }
30 }
31
32 #[packet]
33 pub struct PacketU16 {
34 #[construct_with(u16)]
35 banana: Toto,
36 #[payload]
37 payload: Vec<u8>,
38 }
39
40 fn main() {}