{"action":"opened","number":533,"pull_request":{"url":"https://api.github.com/repos/gtk-rs/gir/pulls/533","id":167003351,"html_url":"https://github.com/gtk-rs/gir/pull/533","diff_url":"https://github.com/gtk-rs/gir/pull/533.diff","patch_url":"https://github.com/gtk-rs/gir/pull/533.patch","issue_url":"https://api.github.com/repos/gtk-rs/gir/issues/533","number":533,"state":"open","locked":false,"title":"Higher level API for XML parsing.","user":{"login":"tmiasko","id":13466935,"avatar_url":"https://avatars0.githubusercontent.com/u/13466935?v=4","gravatar_id":"","url":"https://api.github.com/users/tmiasko","html_url":"https://github.com/tmiasko","followers_url":"https://api.github.com/users/tmiasko/followers","following_url":"https://api.github.com/users/tmiasko/following{/other_user}","gists_url":"https://api.github.com/users/tmiasko/gists{/gist_id}","starred_url":"https://api.github.com/users/tmiasko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmiasko/subscriptions","organizations_url":"https://api.github.com/users/tmiasko/orgs","repos_url":"https://api.github.com/users/tmiasko/repos","events_url":"https://api.github.com/users/tmiasko/events{/privacy}","received_events_url":"https://api.github.com/users/tmiasko/received_events","type":"User","site_admin":false},"body":"Element\r\n=======\r\n\r\nThe most basic building block of new API is new Element type,\r\nwhich wraps StartElement event, and provides following methods:\r\n\r\n```rust\r\n    pub fn name(&self) -> &str;\r\n    pub fn attr(&self, name: &str) -> Option<&str>;\r\n    pub fn attr_required(&self, name: &str) -> Result<&str> {\r\n    pub fn attr_bool(&self, name: &str, default: bool) -> bool;\r\n    pub fn position(&self) -> TextPosition;\r\n    ...\r\n```\r\n\r\nThe `elem.name()` is equivalent to old `name.local_name.as_ref()`.\r\n\r\nPreviously to retrieve an attribute you would write `attr.by_name(\"name\")`.\r\nNow it is `elem.attr(\"name\")`. When attribute is required you can use\r\n`elem.attr_required(\"name\")`. When attribute is absent, appropriate\r\nerror message will be generated that includes file name, line number,\r\ncolumn number, element name and attribute name.\r\n\r\nDocument structure\r\n==================\r\n\r\nPreviously to read all elements inside the current one\r\nand dispatch based on their names one would write following:\r\n\r\n```rust\r\nloop {\r\n    let event = try!(parser.next());\r\n    match event {\r\n        StartElement {\r\n            name, attributes, ..\r\n        } => match name.local_name.as_ref() {\r\n            ...\r\n        }\r\n        EndElement { .. } => break,\r\n        _ => xml_next!(event, parser),\r\n    }\r\n}\r\n```\r\n\r\nNow it can be written as:\r\n\r\n```rust\r\nparser.elements(|parser, elem| match elem.name() {\r\n  ...\r\n})\r\n```\r\n\r\nIn cases when only a single element with specific name is expected,\r\nfollowing can be used: `parser.element_with_name(\"tag\", |parser, elem| ...)`.\r\n\r\nError reporting\r\n===============\r\n\r\n```rust\r\n// Generate custom error and return immediately:\r\nbail!(parser.fail(\"Too many <type> elements\"));\r\n\r\n// Wrap error in Result:\r\nErr(parser.fail(\"Too many <type> elements\"))\r\n\r\n// Using custom position:\r\nparser.fail_with_position(\"Too many <type> elements\", elem.position()));\r\n\r\n// Unexpected element:\r\nparser.unexpected_element(elem)\r\n```","created_at":"2018-02-04T10:07:18Z","updated_at":"2018-02-04T10:07:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/gtk-rs/gir/pulls/533/commits","review_comments_url":"https://api.github.com/repos/gtk-rs/gir/pulls/533/comments","review_comment_url":"https://api.github.com/repos/gtk-rs/gir/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gtk-rs/gir/issues/533/comments","statuses_url":"https://api.github.com/repos/gtk-rs/gir/statuses/dc1e5e9ffb830aaef28703eac5e0d0b0c4689142","head":{"label":"tmiasko:xml","ref":"xml","sha":"dc1e5e9ffb830aaef28703eac5e0d0b0c4689142","user":{"login":"tmiasko","id":13466935,"avatar_url":"https://avatars0.githubusercontent.com/u/13466935?v=4","gravatar_id":"","url":"https://api.github.com/users/tmiasko","html_url":"https://github.com/tmiasko","followers_url":"https://api.github.com/users/tmiasko/followers","following_url":"https://api.github.com/users/tmiasko/following{/other_user}","gists_url":"https://api.github.com/users/tmiasko/gists{/gist_id}","starred_url":"https://api.github.com/users/tmiasko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmiasko/subscriptions","organizations_url":"https://api.github.com/users/tmiasko/orgs","repos_url":"https://api.github.com/users/tmiasko/repos","events_url":"https://api.github.com/users/tmiasko/events{/privacy}","received_events_url":"https://api.github.com/users/tmiasko/received_events","type":"User","site_admin":false},"repo":{"id":119265319,"name":"gir","full_name":"tmiasko/gir","owner":{"login":"tmiasko","id":13466935,"avatar_url":"https://avatars0.githubusercontent.com/u/13466935?v=4","gravatar_id":"","url":"https://api.github.com/users/tmiasko","html_url":"https://github.com/tmiasko","followers_url":"https://api.github.com/users/tmiasko/followers","following_url":"https://api.github.com/users/tmiasko/following{/other_user}","gists_url":"https://api.github.com/users/tmiasko/gists{/gist_id}","starred_url":"https://api.github.com/users/tmiasko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmiasko/subscriptions","organizations_url":"https://api.github.com/users/tmiasko/orgs","repos_url":"https://api.github.com/users/tmiasko/repos","events_url":"https://api.github.com/users/tmiasko/events{/privacy}","received_events_url":"https://api.github.com/users/tmiasko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tmiasko/gir","description":"Tool to generate rust bindings and user API for glib-based libraries","fork":true,"url":"https://api.github.com/repos/tmiasko/gir","forks_url":"https://api.github.com/repos/tmiasko/gir/forks","keys_url":"https://api.github.com/repos/tmiasko/gir/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tmiasko/gir/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tmiasko/gir/teams","hooks_url":"https://api.github.com/repos/tmiasko/gir/hooks","issue_events_url":"https://api.github.com/repos/tmiasko/gir/issues/events{/number}","events_url":"https://api.github.com/repos/tmiasko/gir/events","assignees_url":"https://api.github.com/repos/tmiasko/gir/assignees{/user}","branches_url":"https://api.github.com/repos/tmiasko/gir/branches{/branch}","tags_url":"https://api.github.com/repos/tmiasko/gir/tags","blobs_url":"https://api.github.com/repos/tmiasko/gir/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tmiasko/gir/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tmiasko/gir/git/refs{/sha}","trees_url":"https://api.github.com/repos/tmiasko/gir/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tmiasko/gir/statuses/{sha}","languages_url":"https://api.github.com/repos/tmiasko/gir/languages","stargazers_url":"https://api.github.com/repos/tmiasko/gir/stargazers","contributors_url":"https://api.github.com/repos/tmiasko/gir/contributors","subscribers_url":"https://api.github.com/repos/tmiasko/gir/subscribers","subscription_url":"https://api.github.com/repos/tmiasko/gir/subscription","commits_url":"https://api.github.com/repos/tmiasko/gir/commits{/sha}","git_commits_url":"https://api.github.com/repos/tmiasko/gir/git/commits{/sha}","comments_url":"https://api.github.com/repos/tmiasko/gir/comments{/number}","issue_comment_url":"https://api.github.com/repos/tmiasko/gir/issues/comments{/number}","contents_url":"https://api.github.com/repos/tmiasko/gir/contents/{+path}","compare_url":"https://api.github.com/repos/tmiasko/gir/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tmiasko/gir/merges","archive_url":"https://api.github.com/repos/tmiasko/gir/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tmiasko/gir/downloads","issues_url":"https://api.github.com/repos/tmiasko/gir/issues{/number}","pulls_url":"https://api.github.com/repos/tmiasko/gir/pulls{/number}","milestones_url":"https://api.github.com/repos/tmiasko/gir/milestones{/number}","notifications_url":"https://api.github.com/repos/tmiasko/gir/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tmiasko/gir/labels{/name}","releases_url":"https://api.github.com/repos/tmiasko/gir/releases{/id}","deployments_url":"https://api.github.com/repos/tmiasko/gir/deployments","created_at":"2018-01-28T14:24:35Z","updated_at":"2018-01-28T14:24:37Z","pushed_at":"2018-02-04T10:04:23Z","git_url":"git://github.com/tmiasko/gir.git","ssh_url":"git@github.com:tmiasko/gir.git","clone_url":"https://github.com/tmiasko/gir.git","svn_url":"https://github.com/tmiasko/gir","homepage":"","size":1424,"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":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gtk-rs:master","ref":"master","sha":"0f1d1c178407c918d5cd2fbd5cf67126324cd4ff","user":{"login":"gtk-rs","id":11757045,"avatar_url":"https://avatars2.githubusercontent.com/u/11757045?v=4","gravatar_id":"","url":"https://api.github.com/users/gtk-rs","html_url":"https://github.com/gtk-rs","followers_url":"https://api.github.com/users/gtk-rs/followers","following_url":"https://api.github.com/users/gtk-rs/following{/other_user}","gists_url":"https://api.github.com/users/gtk-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/gtk-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gtk-rs/subscriptions","organizations_url":"https://api.github.com/users/gtk-rs/orgs","repos_url":"https://api.github.com/users/gtk-rs/repos","events_url":"https://api.github.com/users/gtk-rs/events{/privacy}","received_events_url":"https://api.github.com/users/gtk-rs/received_events","type":"Organization","site_admin":false},"repo":{"id":37824715,"name":"gir","full_name":"gtk-rs/gir","owner":{"login":"gtk-rs","id":11757045,"avatar_url":"https://avatars2.githubusercontent.com/u/11757045?v=4","gravatar_id":"","url":"https://api.github.com/users/gtk-rs","html_url":"https://github.com/gtk-rs","followers_url":"https://api.github.com/users/gtk-rs/followers","following_url":"https://api.github.com/users/gtk-rs/following{/other_user}","gists_url":"https://api.github.com/users/gtk-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/gtk-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gtk-rs/subscriptions","organizations_url":"https://api.github.com/users/gtk-rs/orgs","repos_url":"https://api.github.com/users/gtk-rs/repos","events_url":"https://api.github.com/users/gtk-rs/events{/privacy}","received_events_url":"https://api.github.com/users/gtk-rs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gtk-rs/gir","description":"Tool to generate rust bindings and user API for glib-based libraries","fork":false,"url":"https://api.github.com/repos/gtk-rs/gir","forks_url":"https://api.github.com/repos/gtk-rs/gir/forks","keys_url":"https://api.github.com/repos/gtk-rs/gir/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gtk-rs/gir/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gtk-rs/gir/teams","hooks_url":"https://api.github.com/repos/gtk-rs/gir/hooks","issue_events_url":"https://api.github.com/repos/gtk-rs/gir/issues/events{/number}","events_url":"https://api.github.com/repos/gtk-rs/gir/events","assignees_url":"https://api.github.com/repos/gtk-rs/gir/assignees{/user}","branches_url":"https://api.github.com/repos/gtk-rs/gir/branches{/branch}","tags_url":"https://api.github.com/repos/gtk-rs/gir/tags","blobs_url":"https://api.github.com/repos/gtk-rs/gir/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gtk-rs/gir/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gtk-rs/gir/git/refs{/sha}","trees_url":"https://api.github.com/repos/gtk-rs/gir/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gtk-rs/gir/statuses/{sha}","languages_url":"https://api.github.com/repos/gtk-rs/gir/languages","stargazers_url":"https://api.github.com/repos/gtk-rs/gir/stargazers","contributors_url":"https://api.github.com/repos/gtk-rs/gir/contributors","subscribers_url":"https://api.github.com/repos/gtk-rs/gir/subscribers","subscription_url":"https://api.github.com/repos/gtk-rs/gir/subscription","commits_url":"https://api.github.com/repos/gtk-rs/gir/commits{/sha}","git_commits_url":"https://api.github.com/repos/gtk-rs/gir/git/commits{/sha}","comments_url":"https://api.github.com/repos/gtk-rs/gir/comments{/number}","issue_comment_url":"https://api.github.com/repos/gtk-rs/gir/issues/comments{/number}","contents_url":"https://api.github.com/repos/gtk-rs/gir/contents/{+path}","compare_url":"https://api.github.com/repos/gtk-rs/gir/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gtk-rs/gir/merges","archive_url":"https://api.github.com/repos/gtk-rs/gir/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gtk-rs/gir/downloads","issues_url":"https://api.github.com/repos/gtk-rs/gir/issues{/number}","pulls_url":"https://api.github.com/repos/gtk-rs/gir/pulls{/number}","milestones_url":"https://api.github.com/repos/gtk-rs/gir/milestones{/number}","notifications_url":"https://api.github.com/repos/gtk-rs/gir/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gtk-rs/gir/labels{/name}","releases_url":"https://api.github.com/repos/gtk-rs/gir/releases{/id}","deployments_url":"https://api.github.com/repos/gtk-rs/gir/deployments","created_at":"2015-06-21T20:29:55Z","updated_at":"2018-01-16T22:35:43Z","pushed_at":"2018-02-04T08:26:57Z","git_url":"git://github.com/gtk-rs/gir.git","ssh_url":"git@github.com:gtk-rs/gir.git","clone_url":"https://github.com/gtk-rs/gir.git","svn_url":"https://github.com/gtk-rs/gir","homepage":"","size":1436,"stargazers_count":32,"watchers_count":32,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"archived":false,"open_issues_count":57,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":19,"open_issues":57,"watchers":32,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gtk-rs/gir/pulls/533"},"html":{"href":"https://github.com/gtk-rs/gir/pull/533"},"issue":{"href":"https://api.github.com/repos/gtk-rs/gir/issues/533"},"comments":{"href":"https://api.github.com/repos/gtk-rs/gir/issues/533/comments"},"review_comments":{"href":"https://api.github.com/repos/gtk-rs/gir/pulls/533/comments"},"review_comment":{"href":"https://api.github.com/repos/gtk-rs/gir/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gtk-rs/gir/pulls/533/commits"},"statuses":{"href":"https://api.github.com/repos/gtk-rs/gir/statuses/dc1e5e9ffb830aaef28703eac5e0d0b0c4689142"}},"author_association":"CONTRIBUTOR","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":1076,"deletions":1181,"changed_files":4}}
{"actor":{"display_login":"tmiasko"}}