TVF
Tag Value Field is the internal message interface used by ProSA.
It's not a full-fledged format but a Rust trait that defines what a message format should support.
Currently, only the SimpleStringTvf implementation exists. However, in the future, others could implement the TVF trait, such as ProtoBuf, and more.
Usage
In ProSA, Tvf
is used as a generic message type that can support various serialization strategies.
The trait allows you to:
- Add fields using
put_*
methods - Retrieve fields using
get_*
methods - Access information from the container
- ...
Most of the time, when using a component that use TVF, you'll see a generic declaration like:
struct StructObject<M>
where
M: 'static
+ std::marker::Send
+ std::marker::Sync
+ std::marker::Sized
+ std::clone::Clone
+ std::fmt::Debug
+ prosa_utils::msg::tvf::Tvf
+ std::default::Default,
{
fn create_tvf() -> M {
let buffer = M::default();
buffer.put_string(1, "value");
println!("TVF contains: {buffer:?}");
buffer
}
}
To create a TVF, the
Default
trait must be implemented.
Good to have are
Clone
andDebug
for your TVF. When TVFs are used for messaging,Send
andSync
are essential to safely move them across threads.
Implement your own TVF
If you have your own internal format, you can implement the TVF trait on your own and expose your TVF struct:
impl Tvf for MyOwnTvf {
// All trait method must be implement here
}
Make sure to also implement:
Default
: to create an empty or initial TVFSend
/Sync
: to safely transfer across threadsClone
: if duplication of buffers is neededDebug
: To enable easy debugging and inspection
Declare your custom TVF
When you implement your own TVF, you need to expose it in your Cargo.toml metadata as discussed in the previous chapter.
To do this, add the following to your Cargo.toml file:
[package.metadata.prosa]
tvf = ["tvf::MyOwnTvf"]
Be sure to specify the entire path of your implementation, tvf::MyOwnTvf
, in this case, if you place it in src/tvf.rs.
Handling sensitive data
At Worldline, since we process payments, messages may contain sensitive data. This data must not be printed or extracted from the application to ensure security.
To address this, ProSA provides the TvfFilter
trait, which allows filtering and masking sensitive fields.
Depending on your message, sensitive field may vary.
Since TvfFilter
is a trait, you can implement your own filter tailored to your message format.