{"action":"created","comment":{"url":"https://api.github.com/repos/gyscos/zstd-rs/pulls/comments/239493564","pull_request_review_id":182291970,"id":239493564,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzOTQ5MzU2NA==","diff_hunk":"@@ -81,6 +81,20 @@ pub const FRAMEHEADERSIZE_MIN: u32 = zstd_sys::ZSTD_FRAMEHEADERSIZE_MIN;\n pub const FRAMEHEADERSIZE_MAX: u32 = zstd_sys::ZSTD_FRAMEHEADERSIZE_MAX;\n pub const JOBSIZE_MIN: u32 = zstd_sys::ZSTDMT_JOBSIZE_MIN;\n \n+type SafeResult = Result<usize, u32>;\n+\n+/// Parse the result code\n+///\n+/// Returns the number of bytes written if the code represents success,\n+/// or the error message code otherwise.\n+fn parse_code(code: usize) -> SafeResult {\n+    let error_code = unsafe { zstd_sys::ZSTD_isError(code) as u32 };","path":"zstd-safe/src/lib.rs","position":11,"original_position":11,"commit_id":"70c2749a33041d78577a910cdd851cd554c5292d","original_commit_id":"70c2749a33041d78577a910cdd851cd554c5292d","user":{"login":"gyscos","id":564903,"node_id":"MDQ6VXNlcjU2NDkwMw==","avatar_url":"https://avatars0.githubusercontent.com/u/564903?v=4","gravatar_id":"","url":"https://api.github.com/users/gyscos","html_url":"https://github.com/gyscos","followers_url":"https://api.github.com/users/gyscos/followers","following_url":"https://api.github.com/users/gyscos/following{/other_user}","gists_url":"https://api.github.com/users/gyscos/gists{/gist_id}","starred_url":"https://api.github.com/users/gyscos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyscos/subscriptions","organizations_url":"https://api.github.com/users/gyscos/orgs","repos_url":"https://api.github.com/users/gyscos/repos","events_url":"https://api.github.com/users/gyscos/events{/privacy}","received_events_url":"https://api.github.com/users/gyscos/received_events","type":"User","site_admin":false},"body":"I think `ZSTD_isError` just returns a \"boolean\" (a 1 or 0 integer), and not the code itself. C doesn't have booleans, which is why `ZSTD_isError` returns a \"unsigned integer\".\r\nYou probably should use `zstd_safe::is_error` which returns a `bool` and is less confusing.\r\n\r\n```rust\r\ntype SafeResult = Result<usize, usize>; // Why convert to `u32`?\r\n\r\nfn parse_code(code: usize) -> SafeResult {\r\n    if is_error(code) == 0 {\r\n        Ok(code)\r\n    } else {\r\n        Err(code)\r\n    }\r\n} \r\n```","created_at":"2018-12-06T15:23:35Z","updated_at":"2018-12-06T15:23:36Z","html_url":"https://github.com/gyscos/zstd-rs/pull/52#discussion_r239493564","pull_request_url":"https://api.github.com/repos/gyscos/zstd-rs/pulls/52","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/gyscos/zstd-rs/pulls/comments/239493564"},"html":{"href":"https://github.com/gyscos/zstd-rs/pull/52#discussion_r239493564"},"pull_request":{"href":"https://api.github.com/repos/gyscos/zstd-rs/pulls/52"}}},"pull_request":{"url":"https://api.github.com/repos/gyscos/zstd-rs/pulls/52","id":236277752,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM2Mjc3NzUy","html_url":"https://github.com/gyscos/zstd-rs/pull/52","diff_url":"https://github.com/gyscos/zstd-rs/pull/52.diff","patch_url":"https://github.com/gyscos/zstd-rs/pull/52.patch","issue_url":"https://api.github.com/repos/gyscos/zstd-rs/issues/52","number":52,"state":"open","locked":false,"title":"Make zstd_safe really safe","user":{"login":"JakubOnderka","id":163343,"node_id":"MDQ6VXNlcjE2MzM0Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/163343?v=4","gravatar_id":"","url":"https://api.github.com/users/JakubOnderka","html_url":"https://github.com/JakubOnderka","followers_url":"https://api.github.com/users/JakubOnderka/followers","following_url":"https://api.github.com/users/JakubOnderka/following{/other_user}","gists_url":"https://api.github.com/users/JakubOnderka/gists{/gist_id}","starred_url":"https://api.github.com/users/JakubOnderka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakubOnderka/subscriptions","organizations_url":"https://api.github.com/users/JakubOnderka/orgs","repos_url":"https://api.github.com/users/JakubOnderka/repos","events_url":"https://api.github.com/users/JakubOnderka/events{/privacy}","received_events_url":"https://api.github.com/users/JakubOnderka/received_events","type":"User","site_admin":false},"body":"One part of being safe is to check error codes. But current implementation always return usize and return code must be checked in zstd-rs crate. This commit changes the behaviour that zstd-safe functions returns SafeResult.","created_at":"2018-12-05T18:29:25Z","updated_at":"2018-12-06T15:23:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"63661a26841d2119d0385a7b90c58f6c538b9899","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/gyscos/zstd-rs/pulls/52/commits","review_comments_url":"https://api.github.com/repos/gyscos/zstd-rs/pulls/52/comments","review_comment_url":"https://api.github.com/repos/gyscos/zstd-rs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gyscos/zstd-rs/issues/52/comments","statuses_url":"https://api.github.com/repos/gyscos/zstd-rs/statuses/70c2749a33041d78577a910cdd851cd554c5292d","head":{"label":"JakubOnderka:zstd-safe","ref":"zstd-safe","sha":"70c2749a33041d78577a910cdd851cd554c5292d","user":{"login":"JakubOnderka","id":163343,"node_id":"MDQ6VXNlcjE2MzM0Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/163343?v=4","gravatar_id":"","url":"https://api.github.com/users/JakubOnderka","html_url":"https://github.com/JakubOnderka","followers_url":"https://api.github.com/users/JakubOnderka/followers","following_url":"https://api.github.com/users/JakubOnderka/following{/other_user}","gists_url":"https://api.github.com/users/JakubOnderka/gists{/gist_id}","starred_url":"https://api.github.com/users/JakubOnderka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakubOnderka/subscriptions","organizations_url":"https://api.github.com/users/JakubOnderka/orgs","repos_url":"https://api.github.com/users/JakubOnderka/repos","events_url":"https://api.github.com/users/JakubOnderka/events{/privacy}","received_events_url":"https://api.github.com/users/JakubOnderka/received_events","type":"User","site_admin":false},"repo":{"id":139056353,"node_id":"MDEwOlJlcG9zaXRvcnkxMzkwNTYzNTM=","name":"zstd-rs","full_name":"JakubOnderka/zstd-rs","private":false,"owner":{"login":"JakubOnderka","id":163343,"node_id":"MDQ6VXNlcjE2MzM0Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/163343?v=4","gravatar_id":"","url":"https://api.github.com/users/JakubOnderka","html_url":"https://github.com/JakubOnderka","followers_url":"https://api.github.com/users/JakubOnderka/followers","following_url":"https://api.github.com/users/JakubOnderka/following{/other_user}","gists_url":"https://api.github.com/users/JakubOnderka/gists{/gist_id}","starred_url":"https://api.github.com/users/JakubOnderka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakubOnderka/subscriptions","organizations_url":"https://api.github.com/users/JakubOnderka/orgs","repos_url":"https://api.github.com/users/JakubOnderka/repos","events_url":"https://api.github.com/users/JakubOnderka/events{/privacy}","received_events_url":"https://api.github.com/users/JakubOnderka/received_events","type":"User","site_admin":false},"html_url":"https://github.com/JakubOnderka/zstd-rs","description":"A rust binding for the zstd compression library.","fork":true,"url":"https://api.github.com/repos/JakubOnderka/zstd-rs","forks_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/forks","keys_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/teams","hooks_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/hooks","issue_events_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/issues/events{/number}","events_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/events","assignees_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/assignees{/user}","branches_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/branches{/branch}","tags_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/tags","blobs_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/languages","stargazers_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/stargazers","contributors_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/contributors","subscribers_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/subscribers","subscription_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/subscription","commits_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/contents/{+path}","compare_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/merges","archive_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/downloads","issues_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/issues{/number}","pulls_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/labels{/name}","releases_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/releases{/id}","deployments_url":"https://api.github.com/repos/JakubOnderka/zstd-rs/deployments","created_at":"2018-06-28T18:46:40Z","updated_at":"2018-06-28T18:46:42Z","pushed_at":"2018-12-05T18:35:09Z","git_url":"git://github.com/JakubOnderka/zstd-rs.git","ssh_url":"git@github.com:JakubOnderka/zstd-rs.git","clone_url":"https://github.com/JakubOnderka/zstd-rs.git","svn_url":"https://github.com/JakubOnderka/zstd-rs","homepage":null,"size":322,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gyscos:master","ref":"master","sha":"15c10cc9f5cfca48a6f32aeabd25470e0aff4d79","user":{"login":"gyscos","id":564903,"node_id":"MDQ6VXNlcjU2NDkwMw==","avatar_url":"https://avatars0.githubusercontent.com/u/564903?v=4","gravatar_id":"","url":"https://api.github.com/users/gyscos","html_url":"https://github.com/gyscos","followers_url":"https://api.github.com/users/gyscos/followers","following_url":"https://api.github.com/users/gyscos/following{/other_user}","gists_url":"https://api.github.com/users/gyscos/gists{/gist_id}","starred_url":"https://api.github.com/users/gyscos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyscos/subscriptions","organizations_url":"https://api.github.com/users/gyscos/orgs","repos_url":"https://api.github.com/users/gyscos/repos","events_url":"https://api.github.com/users/gyscos/events{/privacy}","received_events_url":"https://api.github.com/users/gyscos/received_events","type":"User","site_admin":false},"repo":{"id":52115335,"node_id":"MDEwOlJlcG9zaXRvcnk1MjExNTMzNQ==","name":"zstd-rs","full_name":"gyscos/zstd-rs","private":false,"owner":{"login":"gyscos","id":564903,"node_id":"MDQ6VXNlcjU2NDkwMw==","avatar_url":"https://avatars0.githubusercontent.com/u/564903?v=4","gravatar_id":"","url":"https://api.github.com/users/gyscos","html_url":"https://github.com/gyscos","followers_url":"https://api.github.com/users/gyscos/followers","following_url":"https://api.github.com/users/gyscos/following{/other_user}","gists_url":"https://api.github.com/users/gyscos/gists{/gist_id}","starred_url":"https://api.github.com/users/gyscos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyscos/subscriptions","organizations_url":"https://api.github.com/users/gyscos/orgs","repos_url":"https://api.github.com/users/gyscos/repos","events_url":"https://api.github.com/users/gyscos/events{/privacy}","received_events_url":"https://api.github.com/users/gyscos/received_events","type":"User","site_admin":false},"html_url":"https://github.com/gyscos/zstd-rs","description":"A rust binding for the zstd compression library.","fork":false,"url":"https://api.github.com/repos/gyscos/zstd-rs","forks_url":"https://api.github.com/repos/gyscos/zstd-rs/forks","keys_url":"https://api.github.com/repos/gyscos/zstd-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gyscos/zstd-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gyscos/zstd-rs/teams","hooks_url":"https://api.github.com/repos/gyscos/zstd-rs/hooks","issue_events_url":"https://api.github.com/repos/gyscos/zstd-rs/issues/events{/number}","events_url":"https://api.github.com/repos/gyscos/zstd-rs/events","assignees_url":"https://api.github.com/repos/gyscos/zstd-rs/assignees{/user}","branches_url":"https://api.github.com/repos/gyscos/zstd-rs/branches{/branch}","tags_url":"https://api.github.com/repos/gyscos/zstd-rs/tags","blobs_url":"https://api.github.com/repos/gyscos/zstd-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gyscos/zstd-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gyscos/zstd-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/gyscos/zstd-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gyscos/zstd-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/gyscos/zstd-rs/languages","stargazers_url":"https://api.github.com/repos/gyscos/zstd-rs/stargazers","contributors_url":"https://api.github.com/repos/gyscos/zstd-rs/contributors","subscribers_url":"https://api.github.com/repos/gyscos/zstd-rs/subscribers","subscription_url":"https://api.github.com/repos/gyscos/zstd-rs/subscription","commits_url":"https://api.github.com/repos/gyscos/zstd-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/gyscos/zstd-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/gyscos/zstd-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/gyscos/zstd-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/gyscos/zstd-rs/contents/{+path}","compare_url":"https://api.github.com/repos/gyscos/zstd-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gyscos/zstd-rs/merges","archive_url":"https://api.github.com/repos/gyscos/zstd-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gyscos/zstd-rs/downloads","issues_url":"https://api.github.com/repos/gyscos/zstd-rs/issues{/number}","pulls_url":"https://api.github.com/repos/gyscos/zstd-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/gyscos/zstd-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/gyscos/zstd-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gyscos/zstd-rs/labels{/name}","releases_url":"https://api.github.com/repos/gyscos/zstd-rs/releases{/id}","deployments_url":"https://api.github.com/repos/gyscos/zstd-rs/deployments","created_at":"2016-02-19T20:44:03Z","updated_at":"2018-12-01T21:07:43Z","pushed_at":"2018-12-05T18:35:10Z","git_url":"git://github.com/gyscos/zstd-rs.git","ssh_url":"git@github.com:gyscos/zstd-rs.git","clone_url":"https://github.com/gyscos/zstd-rs.git","svn_url":"https://github.com/gyscos/zstd-rs","homepage":null,"size":317,"stargazers_count":62,"watchers_count":62,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"archived":false,"open_issues_count":15,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":9,"open_issues":15,"watchers":62,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gyscos/zstd-rs/pulls/52"},"html":{"href":"https://github.com/gyscos/zstd-rs/pull/52"},"issue":{"href":"https://api.github.com/repos/gyscos/zstd-rs/issues/52"},"comments":{"href":"https://api.github.com/repos/gyscos/zstd-rs/issues/52/comments"},"review_comments":{"href":"https://api.github.com/repos/gyscos/zstd-rs/pulls/52/comments"},"review_comment":{"href":"https://api.github.com/repos/gyscos/zstd-rs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gyscos/zstd-rs/pulls/52/commits"},"statuses":{"href":"https://api.github.com/repos/gyscos/zstd-rs/statuses/70c2749a33041d78577a910cdd851cd554c5292d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"gyscos"}}