You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So far, the parse_xcursor() expected a byte slice as its input. Since
the use of this crate is usually in reading cursor files, that means one
has to first load the whole file to memory and then give the result to
this crate, which copies some of that data.
For example, here is wayland-cursor using read_to_end() to load a file
into memory and then passing the result to xcursor-rs:
https://github.com/Smithay/wayland-rs/blob/8fa95cfaae493f748d994ae2aee5433dd183e4ea/wayland-cursor/src/lib.rs#L250-L251
In this commit I want to change this. For API stability reasons, I am
not touching parse_xcursor. Instead, a new function
parse_xcursor_stream() is added. This function can be called with
anything that implements both std::io::Read and Seek. The result is
either a list of images or a std::io::Error. The existing
parse_xcursor() simply forwards to this new function using
std::io::Cursor.
All the parsing functions are changed to take a &mut impl Read. The
internal StreamExt trait is changed to work on Read. Luckily, the use of
Seek is so far contained in parse_xcursor_stream().
Since the new parse_xcursor_stream() function returns an std::io::Error,
tag mismatches need to be turned into such an Error. For that, I simply
used ErrorKind::Other with the text "Tag mismatch". This error is
externally visible through this new function.
No behavioural changes to the code are intended.
Signed-off-by: Uli Schlachter <psychon@znc.in>
0 commit comments