pub trait SomeIpOptions {
    const BYTE_ORDER: ByteOrder = ByteOrder::BigEndian;
    const STRING_WITH_BOM: bool = false;
    const STRING_ENCODING: StringEncoding = StringEncoding::Utf8;
    const STRING_WITH_TERMINATOR: bool = false;
    const DEFAULT_LENGTH_FIELD_SIZE: Option<LengthFieldSize> = _;
    const SERIALIZER_USE_LEGACY_WIRE_TYPE: bool = false;
    const SERIALIZER_LENGTH_FIELD_SIZE_SELECTION: LengthFieldSizeSelection = LengthFieldSizeSelection::Smallest;
    const DESERIALIZER_STRICT_BOOL: bool = false;
    const DESERIALIZER_ACTION_ON_TOO_MUCH_DATA: ActionOnTooMuchData = ActionOnTooMuchData::Discard;

    fn verify_string_encoding() { ... }
    fn from_reader<T, Reader>(reader: Reader, len: usize) -> Result<T>
    where
        T: DeserializeOwned + SomeIp + ?Sized,
        Reader: Read
, { ... } fn from_slice<'a, T>(slice: &'a [u8]) -> Result<T>
    where
        T: Deserialize<'a> + SomeIp + ?Sized
, { ... } fn from_bytes<T>(data: Bytes) -> Result<T>
    where
        T: DeserializeOwned + SomeIp + ?Sized
, { ... } fn to_vec<T>(value: &T) -> Result<Vec<u8>>
    where
        T: Serialize + SomeIp
, { ... } fn append_to_vec<T>(value: &T, vec: &mut Vec<u8>) -> Result<()>
    where
        T: Serialize + SomeIp
, { ... } fn to_bytes<T>(value: &T) -> Result<Bytes>
    where
        T: Serialize + SomeIp
, { ... } fn append_to_bytes<T>(value: &T, bytes: &mut BytesMut) -> Result<()>
    where
        T: Serialize + SomeIp
, { ... } }
Expand description

The options to use for de/serialization.

It is expected that these will be almost always identical, since they are usually defined once either per project or even per vehicle OEM.

This trait also provides some convenience functions for serializing/deserializing:

use serde_someip::{SomeIpOptions, to_vec, from_slice};

let manually = to_vec::<ExampleOptions, _>(&42u32).unwrap();
let convenience = ExampleOptions::to_vec(&42u32).unwrap();

assert_eq!(manually, convenience);

let manually: u32 =  from_slice::<ExampleOptions, _>(&manually).unwrap();
let convenience: u32 = ExampleOptions::from_slice(&convenience).unwrap();

assert_eq!(manually, convenience);

Provided Associated Constants§

The byte order to use

If strings must start with a BOM.

Setting this to true while using Ascii is an error, since the BOM char is not part of the ASCII char set.

If true and the encoding is any utf-16 encoding the deserializer will dynamically determine the byte order of strings based on the BOM.

The encoding used by strings

If strings must end with a null terminator.

The default length field size to use if the type does not define one.

Should the serializer output the legacy wire type for length delimited fields?

By default wiretypes 5(length delimited one byte), 6(length delimited two bytes) or 7(length delimited four bytes) are used for length delimited fields by enabling this option wiretype 4(length delimited from config) will be used if the length fields size equals the one that was statically configured.

How the size of the length field size should be selected, see LengthFieldSizeSelection.

Should the deserializer issue a error if a bool is expected and a u8 > 1 is encountered?

Usually only 0 and 1 are allowed for booleans but misbehaving implementations may send larger values. With strict booleans such values lead to InvalidBool in lenient mode they are interpreted as true.

How the deserializer treats strings or sequnces with too much data, see ActionOnTooMuchData.

Provided Methods§

Verifies that the string encoding is valid.

Panics

Panics if the string encoding is invalid.

Convenience wrapper for super::from_reader

Convenience wrapper for super::from_slice

Convenience wrapper for super::from_bytes

Only available with the bytes feature.

Convenience wrapper for super::to_vec

Convenience wrapper for super::append_to_vec

Convenience wrapper for super::to_bytes

Only available with the bytes feature.

Convenience wrapper for super::append_to_bytes

Only available with the bytes feature.

Implementors§