Hi,
I would like to serialize Strings, str, structures, Vec, etc. into byte streams and with one function. Is this even possible?
example:
pub struct AS<T> {
x: T,
}
pub struct A {
x: i32,
}
fn make_bytes<T>(payload: T) // I would like my payload to be Vec or String or structure or ...
{
let bytes = bincode::serialize(&payload).unwrap();
println!("{:?}", bytes);
}
In order to overload make_bytes I tried to do the same as in c++ but it did not work. So i guess my first question is is is possible to overload functions and how? And my second question is, if I use generics I get that serialize cannot work with them... Could someone please help and workout a small example for me so I ca study it ?
thnx