{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rfcs/pulls/comments/26641831","id":26641831,"diff_hunk":"@@ -0,0 +1,50 @@\n+- Feature Name: read_all\n+- Start Date: 2015-03-15\n+- RFC PR: (leave this empty)\n+- Rust Issue: (leave this empty)\n+\n+# Summary\n+\n+Rust's Write trait has write_all, which attempts to write an entire\n+buffer.  This proposal adds read_all, which attempts to read a fixed\n+number of bytes into a given buffer.\n+\n+# Motivation\n+\n+The new read_all method will allow programs to read from disk without\n+having to write their own read loops.  Most Rust programs which need\n+to read from disk will prefer this to the plain read function.  Many C\n+programs have the same need, and solve it the same way (e.g. git has\n+read_in_full).  Here's one example of a Rust library doing this:\n+https://github.com/BurntSushi/byteorder/blob/master/src/new.rs#L184\n+\n+# Detailed design\n+\n+The read_all function will take a mutable, borrowed slice of u8 to\n+read into, and will attempt to fill that entire slice with data.\n+\n+It will loop, calling read() once per iteration and attempting to read\n+the remaining amount of data.  If read returns EINTR, the loop will\n+retry.  If there are no more bytes to read (as signalled by a return\n+of Ok(0) from read()), a new error type, ErrorKind::ReadZero, will be\n+returned.  In the event of another error, that error will be\n+returned. After a read call returns having successfully read some\n+bytes, the total number of bytes read will be updated.  If that\n+total is equal to the size of the buffer, read will return\n+successfully.","path":"text/0000-read-all.md","position":34,"original_position":34,"commit_id":"6566a1d5a17e4e38dd2c176b7325c599d34f0d93","original_commit_id":"288b1b522b048f821b447ce496e38f1276615a74","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"body":"> Is it a four byte difference between i32 errno and u64 usize that we're talking here?\r\n\r\nNo that's probably manageable, I just wanted to point out that the size of `io::Error` is a very real worry and it can be affected by `ErrorKind` depending on how we're implementing it.\r\n\r\n> Making a separate error type for this method might be the most straightforward approach.\r\n\r\nThis is possible, but has drawbacks:\r\n\r\n* More API surface area to stabilize\r\n* Nonstandard as the very similar `write_all` API would probably also want this treatment.\r\n* Can hinder understanding by returning a non-normal error type.\r\n* Operating generically over I/O functions may be hindered as this would stick out.","created_at":"2015-03-18T07:01:33Z","updated_at":"2015-03-18T07:01:33Z","html_url":"https://github.com/rust-lang/rfcs/pull/980#discussion_r26641831","pull_request_url":"https://api.github.com/repos/rust-lang/rfcs/pulls/980","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/comments/26641831"},"html":{"href":"https://github.com/rust-lang/rfcs/pull/980#discussion_r26641831"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/980"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rfcs/pulls/980","id":31206014,"html_url":"https://github.com/rust-lang/rfcs/pull/980","diff_url":"https://github.com/rust-lang/rfcs/pull/980.diff","patch_url":"https://github.com/rust-lang/rfcs/pull/980.patch","issue_url":"https://api.github.com/repos/rust-lang/rfcs/issues/980","number":980,"state":"open","locked":false,"title":"RFC for read_all","user":{"login":"novalis","id":77003,"avatar_url":"https://avatars.githubusercontent.com/u/77003?v=3","gravatar_id":"","url":"https://api.github.com/users/novalis","html_url":"https://github.com/novalis","followers_url":"https://api.github.com/users/novalis/followers","following_url":"https://api.github.com/users/novalis/following{/other_user}","gists_url":"https://api.github.com/users/novalis/gists{/gist_id}","starred_url":"https://api.github.com/users/novalis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novalis/subscriptions","organizations_url":"https://api.github.com/users/novalis/orgs","repos_url":"https://api.github.com/users/novalis/repos","events_url":"https://api.github.com/users/novalis/events{/privacy}","received_events_url":"https://api.github.com/users/novalis/received_events","type":"User","site_admin":false},"body":"Code for this: https://github.com/rust-lang/rust/pull/23369","created_at":"2015-03-15T19:53:43Z","updated_at":"2015-03-18T07:01:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"330bbbbd30b941b2cab5fdb1c22bb9251ad61220","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rfcs/pulls/980/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rfcs/pulls/980/comments","review_comment_url":"https://api.github.com/repos/rust-lang/rfcs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/issues/980/comments","statuses_url":"https://api.github.com/repos/rust-lang/rfcs/statuses/6566a1d5a17e4e38dd2c176b7325c599d34f0d93","head":{"label":"novalis:novalis/read-all","ref":"novalis/read-all","sha":"6566a1d5a17e4e38dd2c176b7325c599d34f0d93","user":{"login":"novalis","id":77003,"avatar_url":"https://avatars.githubusercontent.com/u/77003?v=3","gravatar_id":"","url":"https://api.github.com/users/novalis","html_url":"https://github.com/novalis","followers_url":"https://api.github.com/users/novalis/followers","following_url":"https://api.github.com/users/novalis/following{/other_user}","gists_url":"https://api.github.com/users/novalis/gists{/gist_id}","starred_url":"https://api.github.com/users/novalis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novalis/subscriptions","organizations_url":"https://api.github.com/users/novalis/orgs","repos_url":"https://api.github.com/users/novalis/repos","events_url":"https://api.github.com/users/novalis/events{/privacy}","received_events_url":"https://api.github.com/users/novalis/received_events","type":"User","site_admin":false},"repo":{"id":32280646,"name":"rfcs","full_name":"novalis/rfcs","owner":{"login":"novalis","id":77003,"avatar_url":"https://avatars.githubusercontent.com/u/77003?v=3","gravatar_id":"","url":"https://api.github.com/users/novalis","html_url":"https://github.com/novalis","followers_url":"https://api.github.com/users/novalis/followers","following_url":"https://api.github.com/users/novalis/following{/other_user}","gists_url":"https://api.github.com/users/novalis/gists{/gist_id}","starred_url":"https://api.github.com/users/novalis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novalis/subscriptions","organizations_url":"https://api.github.com/users/novalis/orgs","repos_url":"https://api.github.com/users/novalis/repos","events_url":"https://api.github.com/users/novalis/events{/privacy}","received_events_url":"https://api.github.com/users/novalis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/novalis/rfcs","description":"RFCs for changes to Rust","fork":true,"url":"https://api.github.com/repos/novalis/rfcs","forks_url":"https://api.github.com/repos/novalis/rfcs/forks","keys_url":"https://api.github.com/repos/novalis/rfcs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/novalis/rfcs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/novalis/rfcs/teams","hooks_url":"https://api.github.com/repos/novalis/rfcs/hooks","issue_events_url":"https://api.github.com/repos/novalis/rfcs/issues/events{/number}","events_url":"https://api.github.com/repos/novalis/rfcs/events","assignees_url":"https://api.github.com/repos/novalis/rfcs/assignees{/user}","branches_url":"https://api.github.com/repos/novalis/rfcs/branches{/branch}","tags_url":"https://api.github.com/repos/novalis/rfcs/tags","blobs_url":"https://api.github.com/repos/novalis/rfcs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/novalis/rfcs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/novalis/rfcs/git/refs{/sha}","trees_url":"https://api.github.com/repos/novalis/rfcs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/novalis/rfcs/statuses/{sha}","languages_url":"https://api.github.com/repos/novalis/rfcs/languages","stargazers_url":"https://api.github.com/repos/novalis/rfcs/stargazers","contributors_url":"https://api.github.com/repos/novalis/rfcs/contributors","subscribers_url":"https://api.github.com/repos/novalis/rfcs/subscribers","subscription_url":"https://api.github.com/repos/novalis/rfcs/subscription","commits_url":"https://api.github.com/repos/novalis/rfcs/commits{/sha}","git_commits_url":"https://api.github.com/repos/novalis/rfcs/git/commits{/sha}","comments_url":"https://api.github.com/repos/novalis/rfcs/comments{/number}","issue_comment_url":"https://api.github.com/repos/novalis/rfcs/issues/comments{/number}","contents_url":"https://api.github.com/repos/novalis/rfcs/contents/{+path}","compare_url":"https://api.github.com/repos/novalis/rfcs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/novalis/rfcs/merges","archive_url":"https://api.github.com/repos/novalis/rfcs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/novalis/rfcs/downloads","issues_url":"https://api.github.com/repos/novalis/rfcs/issues{/number}","pulls_url":"https://api.github.com/repos/novalis/rfcs/pulls{/number}","milestones_url":"https://api.github.com/repos/novalis/rfcs/milestones{/number}","notifications_url":"https://api.github.com/repos/novalis/rfcs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/novalis/rfcs/labels{/name}","releases_url":"https://api.github.com/repos/novalis/rfcs/releases{/id}","created_at":"2015-03-15T19:52:45Z","updated_at":"2015-03-15T16:57:39Z","pushed_at":"2015-03-18T04:57:43Z","git_url":"git://github.com/novalis/rfcs.git","ssh_url":"git@github.com:novalis/rfcs.git","clone_url":"https://github.com/novalis/rfcs.git","svn_url":"https://github.com/novalis/rfcs","homepage":"","size":10682,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"3857a25938bda0147f90f9a3cbfc176ebb768884","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":17527989,"name":"rfcs","full_name":"rust-lang/rfcs","owner":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang/rfcs","description":"RFCs for changes to Rust","fork":false,"url":"https://api.github.com/repos/rust-lang/rfcs","forks_url":"https://api.github.com/repos/rust-lang/rfcs/forks","keys_url":"https://api.github.com/repos/rust-lang/rfcs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/rfcs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/rfcs/teams","hooks_url":"https://api.github.com/repos/rust-lang/rfcs/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/rfcs/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/rfcs/events","assignees_url":"https://api.github.com/repos/rust-lang/rfcs/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/rfcs/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/rfcs/tags","blobs_url":"https://api.github.com/repos/rust-lang/rfcs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/rfcs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/rfcs/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/rfcs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/rfcs/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/rfcs/languages","stargazers_url":"https://api.github.com/repos/rust-lang/rfcs/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/rfcs/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/rfcs/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/rfcs/subscription","commits_url":"https://api.github.com/repos/rust-lang/rfcs/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/rfcs/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/rfcs/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/rfcs/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/rfcs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/rfcs/merges","archive_url":"https://api.github.com/repos/rust-lang/rfcs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/rfcs/downloads","issues_url":"https://api.github.com/repos/rust-lang/rfcs/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/rfcs/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/rfcs/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/rfcs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/rfcs/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/rfcs/releases{/id}","created_at":"2014-03-07T21:29:00Z","updated_at":"2015-03-17T14:21:22Z","pushed_at":"2015-03-17T17:47:45Z","git_url":"git://github.com/rust-lang/rfcs.git","ssh_url":"git@github.com:rust-lang/rfcs.git","clone_url":"https://github.com/rust-lang/rfcs.git","svn_url":"https://github.com/rust-lang/rfcs","homepage":"","size":10682,"stargazers_count":284,"watchers_count":284,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":176,"mirror_url":null,"open_issues_count":477,"forks":176,"open_issues":477,"watchers":284,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/980"},"html":{"href":"https://github.com/rust-lang/rfcs/pull/980"},"issue":{"href":"https://api.github.com/repos/rust-lang/rfcs/issues/980"},"comments":{"href":"https://api.github.com/repos/rust-lang/rfcs/issues/980/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/980/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/980/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rfcs/statuses/6566a1d5a17e4e38dd2c176b7325c599d34f0d93"}}}}