First of all, thanks for making this crate available, it's really awesome work. I really like the idea to base this on serde and also the convenience and readability it brings.
I am currently trying out this crate in a client that talks to a service that uses vsomeip. I assume this might be a common use case. So I thought I'd share the SomeIpOptions
implementations that worked for me, hoping that it will relieve the next one who tries this from digging in the common someip runtime code.
This assumes common someip runtime defaults (_dep == nullptr
) and may need some tweaking depending on ones custom configuration.
pub struct VSomeIpDefaultOptions {}
impl SomeIpOptions for VSomeIpDefaultOptions {
const BYTE_ORDER: serde_someip::options::ByteOrder = serde_someip::options::ByteOrder::BigEndian;
// https://github.com/COVESA/capicxx-someip-runtime/blob/0ad2bdc1807fc0f078b9f9368a47ff2f3366ed13/src/CommonAPI/SomeIP/OutputStream.cpp#L368
const STRING_WITH_BOM: bool = true;
const STRING_ENCODING: serde_someip::options::StringEncoding = serde_someip::options::StringEncoding::Utf8;
// https://github.com/COVESA/capicxx-someip-runtime/blob/0ad2bdc1807fc0f078b9f9368a47ff2f3366ed13/src/CommonAPI/SomeIP/OutputStream.cpp#L228
const STRING_WITH_TERMINATOR: bool = true;
// https://github.com/COVESA/capicxx-someip-runtime/blob/0ad2bdc1807fc0f078b9f9368a47ff2f3366ed13/src/CommonAPI/SomeIP/OutputStream.cpp#L246
const DEFAULT_LENGTH_FIELD_SIZE: Option<serde_someip::length_fields::LengthFieldSize> = Some(serde_someip::length_fields::LengthFieldSize::FourBytes);
// https://github.com/COVESA/capicxx-someip-runtime/blob/0ad2bdc1807fc0f078b9f9368a47ff2f3366ed13/src/CommonAPI/SomeIP/OutputStream.cpp#L246
const OVERWRITE_LENGTH_FIELD_SIZE: Option<serde_someip::length_fields::LengthFieldSize> = Some(serde_someip::length_fields::LengthFieldSize::FourBytes);
const SERIALIZER_USE_LEGACY_WIRE_TYPE: bool = false;
const SERIALIZER_LENGTH_FIELD_SIZE_SELECTION: serde_someip::options::LengthFieldSizeSelection =
serde_someip::options::LengthFieldSizeSelection::AsConfigured;
const DESERIALIZER_STRICT_BOOL: bool = false;
const DESERIALIZER_ACTION_ON_TOO_MUCH_DATA: serde_someip::options::ActionOnTooMuchData = serde_someip::options::ActionOnTooMuchData::Fail;
}
I had one interesting case when using ActionOnTooMuchData::Discard
that I ran into CannotCodeString("String muse end with 0 terminator")
because I had specified the max_size
in Rust too short and the terminator was basically discarded.
Even worse the difference between max_size
and actual size was only the terminator in my case, so setting STRING_WITH_TERMINATOR
to false
magically made the deserialization work ;).
One could say that is the definition of Discard
, I'm just leaving it here for the next one who runs into this.