File: construct-with-errors.rs

package info (click to toggle)
rust-pnet-macros 0.35.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 384 kB
  • sloc: makefile: 2
file content (59 lines) | stat: -rw-r--r-- 1,513 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2021 Pierre Chifflier <chifflier@wzdftpd.net>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern crate pnet_macros;
extern crate pnet_macros_support;
use pnet_macros::packet;

#[derive(Clone, Debug)]
pub struct Toto{
    dummy: u16,
}

#[packet]
pub struct PacketU16 {
    #[construct_with()] //~ ERROR #[construct_with] must have at least one argument
    banana: Toto,
    #[payload]
    payload: Vec<u8>,
}

#[packet]
pub struct PacketU16B {
    #[construct_with("test")] //~ ERROR #[construct_with] should be of the form #[construct_with(<primitive types>)]
    banana: Toto,
    #[payload]
    payload: Vec<u8>,
}

#[packet]
pub struct PacketU16C {
    #[construct_with(::foo:bar)] //~ ERROR #[construct_with] should be of the form #[construct_with(<primitive types>)]
    banana: Toto,
    #[payload]
    payload: Vec<u8>,
}

#[packet]
pub struct PacketU16D {
    #[construct_with(Vec<u8>)] //~ ERROR #[construct_with] should be of the form #[construct_with(<primitive types>)]
    banana: Toto,
    #[payload]
    payload: Vec<u8>,
}

#[packet]
pub struct PacketU16E {
    #[construct_with(test)] //~ ERROR arguments to #[construct_with] must be primitives
    banana: Toto,
    #[payload]
    payload: Vec<u8>,
}


fn main() {}