Remove string cow#142
Conversation
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
|
@tafia Any feedback on these kind of changes? |
|
Sorry for the late answer. Looks really nice but I need to find some time to test it properly. I am sorry it is taking so long but I don't have much time at the moment. I'll try to have a look this week-end |
|
So I am looking at the PR (thanks again!). I agree that it simplifies things quite a lot but unless I'm missing something I don't understand how people are supposed to use it in practice, I mean using I would be happy to have a special flag to enable this type of scenario (with some comment explaining the rationale). Also for #[no_std] i believe that with the last rust release (stabilization of the alloc crate) we should be able to handle |
I'm not sure I understand what you mean by serialisation. Generate protobuf messages from Rust? I'm doing that right here: https://github.com/axiros/rusp/blob/no-cow-string-experiment/src/usp_generator.rs#L372 and the data comes in from the CLI via a Option which can be as easily turning into a &str as it is turning into a
It's not that easy, even if there was a compatible allocator (which there isn't), the available heap will be of a static rather limited size so I'd expect tossing strings around will still need careful consideration and in many if not most cases be a no-go. Reliability is key in embedded, so one would definitely want to avoid code that might panic due to out-of-memory situations and not even run on some configurations at all. |
|
Sorry if I wasn't clear. In your example, you don't take ownership of Correct me if i'm wrong but your variant works well for situations where the messages are just temporary struct used to import / export data into protobuf, not for more general purpose situations. Regarding Again I would be happy to provide this no-cow version behind a flag. |
Uhm, the caller of the function has ownership of the value, cf. https://github.com/axiros/rusp/blob/no-cow-string-experiment/src/main.rs#L316. The reason I'm taking a I'm actually not quite sure why you're even using |
|
Also somehow linked #143 |
|
Having the ability to change the string values in messages helps my app quite a bit. I'm not sure how I'd use quick-protobuf if all the messages were tied to the lifetime where they were created. Note: I'm using tokio + futures quite a bit, so I think the messages must have a |
|
@tafia To be honest I have no idea what the advantage of using rental in this context would be. |
|
@nerdrew I'm using the actix framework and haven't encountered any troubles yet but I can run some more exhaustive tests. |
|
Conflicted by #158 |
This is mostly an ergonomics change. Getting rid of Cow for strings removes a substantial amount of boilerplate and brings us a tiny step closer to being able to use quick-protobuf with
no_std.I've converted a project to use the improvement as an experiment if you'd like to take a look: https://github.com/axiros/rusp/tree/no-cow-string-experiment