Closed kchibisov closed 4 years ago
I wonder if we should rather do some best-effort processing, reading the contents into a Vec
, then converting it using String::from_utf8 and using String::from_utf8_lossy as a fallback.
Honestly sounds like a terrible idea. To me there is no logical explanation why someone would want to paste an image as text.
I wonder if we should rather do some best-effort processing, reading the contents into a Vec
, then converting it using String::from_utf8 and using String::from_utf8_lossy as a fallback.
Well, we're requesting utf8 string, we got non-utf8 string marked as utf8 string, so It doesn't make any sense to speculate on that and trying to make something different out of it.
OK, but silently ignoring the error sounds bad to me.
In that case, maybe the clipboard access should signal the error to downstream crates (by returning a Result), so that they decide if/how they inform the user that the clipboard contained invalid data.
in theory clipboard should return Vec<u8>
data and mime
type, so the client will parse it later to something more useful, since clipboard isn't supposed to work only with utf8 text. We can return result for now though.
in theory clipboard should return
Vec<u8>
data andmime
type, so the client will parse it later to something more useful, since clipboard isn't supposed to work only with utf8 text.
This would require a more complex API though, given a single clipboard item can be provided as several different mime types, from which the receiver can choose which one is more convenient.
I've decided to return Result<String>
for now, since we don't handle other mime types anyway.
I wonder if we should rather do some best-effort processing, reading the contents into a Vec, then converting it using String::from_utf8 and using String::from_utf8_lossy as a fallback.