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
// Copyright 2016 James Bendig. See the COPYRIGHT file at the top-level
// directory of this distribution.
//
// Licensed under:
//   the MIT license
//     <LICENSE-MIT or https://opensource.org/licenses/MIT>
//   or the Apache License, Version 2.0
//     <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>,
// at your option. This file may not be copied, modified, or distributed
// except according to those terms.

use fix_version::FIXVersion;
use message::{Message,SetValueError};
use message_version::MessageVersion;
use rule::Rule;

pub trait FieldType {
    type Type;

    fn rule() -> Option<Rule> {
        None
    }

    fn default_value() -> Self::Type;

    fn set_value(_field: &mut Self::Type,_bytes: &[u8]) -> Result<(),SetValueError> {
        Err(SetValueError::WrongFormat)
    }

    fn set_groups(_field: &mut Self::Type,_groups: &[Box<Message>]) -> bool {
        false
    }

    fn is_empty(field: &Self::Type) -> bool;
    fn len(field: &Self::Type) -> usize;
    fn read(field: &Self::Type,fix_version: FIXVersion,message_version: MessageVersion,buf: &mut Vec<u8>) -> usize;
}