Usually the serialization/deserialization code, I keep with the model. The part where a file or whatever comes in, I leave that to the caller to decide on. In other words, the model knows how to serialize and deserialize itself, but not where it’s being serialized to or deserialized from.
Then again, in C#, it’s usually just a couple attributes on my model, and in Rust, it’s usually just a couple derives. It’s rare I actually write much, if any, serialization logic by hand.
Usually the serialization/deserialization code, I keep with the model. The part where a file or whatever comes in, I leave that to the caller to decide on. In other words, the model knows how to serialize and deserialize itself, but not where it’s being serialized to or deserialized from.
Then again, in C#, it’s usually just a couple attributes on my model, and in Rust, it’s usually just a couple derives. It’s rare I actually write much, if any, serialization logic by hand.