{"action":"created","issue":{"url":"https://api.github.com/repos/gtk-rs/gio/issues/160","repository_url":"https://api.github.com/repos/gtk-rs/gio","labels_url":"https://api.github.com/repos/gtk-rs/gio/issues/160/labels{/name}","comments_url":"https://api.github.com/repos/gtk-rs/gio/issues/160/comments","events_url":"https://api.github.com/repos/gtk-rs/gio/issues/160/events","html_url":"https://github.com/gtk-rs/gio/issues/160","id":370087402,"node_id":"MDU6SXNzdWUzNzAwODc0MDI=","number":160,"title":"Provide a way to use std::io::{Read,Write} and gio::{Input,Output}Stream interchangeably","user":{"login":"fkrull","id":2378306,"node_id":"MDQ6VXNlcjIzNzgzMDY=","avatar_url":"https://avatars0.githubusercontent.com/u/2378306?v=4","gravatar_id":"","url":"https://api.github.com/users/fkrull","html_url":"https://github.com/fkrull","followers_url":"https://api.github.com/users/fkrull/followers","following_url":"https://api.github.com/users/fkrull/following{/other_user}","gists_url":"https://api.github.com/users/fkrull/gists{/gist_id}","starred_url":"https://api.github.com/users/fkrull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fkrull/subscriptions","organizations_url":"https://api.github.com/users/fkrull/orgs","repos_url":"https://api.github.com/users/fkrull/repos","events_url":"https://api.github.com/users/fkrull/events{/privacy}","received_events_url":"https://api.github.com/users/fkrull/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-15T10:00:45Z","updated_at":"2018-10-15T10:28:54Z","closed_at":null,"author_association":"NONE","body":"When you have a `std::io::Read`, it should be possible to use it with gio-based APIs that require a `gio::InputStream`. Conversely, when all you have is a `gio::InputStream`, it should be possible to use it with APIs using `std::io::Read`. The same goes `std::io::Write` and `gio::OutputStream`.\r\n\r\nWhen mixing APIs using the Rust types and the gio types, interaction between streams gets hairy. Writing a wrapper for `gio::{Input,Output}Stream` that implements Read or Write is straightforward enough, but it's also generally useful so IMO it should be included here. However, if all you have is an `std::io::Read`, the only way I've found to get that to an API that takes a `gio::InputStream` is to dump the entire stream into a temporary file and re-open that with gio. I think it should be possible to write a gobject subclass of GInputStream -- either in unsafe Rust or in C -- that simply wraps a `std::io::Read`. This class would then have to be exposed back to Rust in some form.\r\n\r\nSo in short, things I'd love to see:\r\n* a wrapper for `gio::InputStream` that implements `std::io::Read`\r\n* a wrapper for `gio::OutputStream` that implements `std::io::Write`\r\n* a subclass of `GInputStream` that wraps a `std::io::Read` and can be passed to wrapped APIs\r\n* a subclass of `GOutputStream` that wraps a `std::io::Write` and can be passed to wrapped APIs\r\n"},"comment":{"url":"https://api.github.com/repos/gtk-rs/gio/issues/comments/429793730","html_url":"https://github.com/gtk-rs/gio/issues/160#issuecomment-429793730","issue_url":"https://api.github.com/repos/gtk-rs/gio/issues/160","id":429793730,"node_id":"MDEyOklzc3VlQ29tbWVudDQyOTc5MzczMA==","user":{"login":"sdroege","id":301846,"node_id":"MDQ6VXNlcjMwMTg0Ng==","avatar_url":"https://avatars3.githubusercontent.com/u/301846?v=4","gravatar_id":"","url":"https://api.github.com/users/sdroege","html_url":"https://github.com/sdroege","followers_url":"https://api.github.com/users/sdroege/followers","following_url":"https://api.github.com/users/sdroege/following{/other_user}","gists_url":"https://api.github.com/users/sdroege/gists{/gist_id}","starred_url":"https://api.github.com/users/sdroege/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdroege/subscriptions","organizations_url":"https://api.github.com/users/sdroege/orgs","repos_url":"https://api.github.com/users/sdroege/repos","events_url":"https://api.github.com/users/sdroege/events{/privacy}","received_events_url":"https://api.github.com/users/sdroege/received_events","type":"User","site_admin":false},"created_at":"2018-10-15T10:28:54Z","updated_at":"2018-10-15T10:28:54Z","author_association":"MEMBER","body":"For the first two, you could add an impl for `Read`/`Write` directly on `GInputStream`/`GOutputStream`. Do you want to provide a PR for that?\r\n\r\nThe other two are a bit more involved as the subclassing story in Rust is not great yet. You can either do it with a bit of unsafe code doing basically the same as one would do in C (which is probably preferred for this case here), or around https://github.com/gtk-rs/gobject-subclass for a generic solution."}}
{"actor":{"display_login":"sdroege"}}