{"action":"created","comment":{"url":"https://api.github.com/repos/szeged/servo/pulls/comments/58505869","id":58505869,"diff_hunk":"@@ -40,59 +54,210 @@ impl Bluetooth {\n     }\n }\n \n+impl Clone for StringOrUnsignedLong {\n+    fn clone(&self) -> StringOrUnsignedLong {\n+        match self {\n+            &StringOrUnsignedLong::String(ref s) => StringOrUnsignedLong::String(s.clone()),\n+            &StringOrUnsignedLong::UnsignedLong(usl) => StringOrUnsignedLong::UnsignedLong(usl),\n+        }\n+    }\n+}\n+\n+impl Clone for BluetoothScanFilter {\n+    fn clone(&self) -> BluetoothScanFilter {\n+        match self.services {\n+            None => BluetoothScanFilter {\n+                name: self.name.clone(),\n+                namePrefix: self.namePrefix.clone(),\n+                services: None,\n+            },\n+            Some(ref vec) => BluetoothScanFilter {\n+                name: self.name.clone(),\n+                namePrefix: self.namePrefix.clone(),\n+                services: Some(vec.clone()),\n+            },\n+        }\n+    }\n+}\n+\n+impl Clone for RequestDeviceOptions {\n+    fn clone(&self) -> RequestDeviceOptions {\n+        match self.optionalServices {\n+            None => RequestDeviceOptions {\n+                filter: self.filter.clone(),\n+                optionalServices: None,\n+            },\n+            Some(ref vec) => RequestDeviceOptions {\n+                filter: self.filter.clone(),\n+                optionalServices: Some(vec.clone()),\n+            }\n+        }\n+    }\n+}\n+\n+fn canonicalize_filter(filter: &BluetoothScanFilter, global: GlobalRef)\n+    -> Fallible<BluetoothScanfilter> {\n+\n+    if !(filter.services.is_some() ||\n+         filter.name.is_some() ||\n+         filter.namePrefix.is_some()) {\n+        return Err(Type(\"A filter must restrict the devices in some way.\".to_owned()));\n+    }\n+\n+    let mut services: Vec<String> = vec!();\n+    if filter.services.is_some() {\n+        if filter.services.clone().unwrap().is_empty() {\n+            return Err(Type(\"'services', if present, must contain at least one service.\".to_owned()));\n+        }\n+        for service in filter.services.clone().unwrap() {\n+            let validated_service = BluetoothUUID::GetService(global, service);\n+            match validated_service {\n+                Err(err) => return Err(err),\n+                Ok(valid) => services.push(valid.to_string()),\n+            }\n+        }\n+    }\n+\n+    let mut name = String::new();\n+    if filter.name.is_some() {\n+        // DOMString::len() gives back the size in bytes\n+        let name_lenght = filter.name.clone().unwrap().len();\n+        if name_lenght > MAX_DEVICE_NAME_LENGTH {\n+            return Err(Type(NAME_TOO_LONG_EXCEPTION.to_owned()));\n+        }\n+        if name_lenght > MAX_FILTER_NAME_LENGTH {\n+            return Err(Type(FILTER_NAME_TOO_LONG_EXCEPTION.to_owned()));\n+        }\n+        name = filter.name","path":"components/script/dom/bluetooth.rs","position":112,"original_position":112,"commit_id":"3afa14fe23f3c8ab5cd7ccedc25f297d349c3771","original_commit_id":"3afa14fe23f3c8ab5cd7ccedc25f297d349c3771","user":{"login":"dati91","id":2149430,"avatar_url":"https://avatars.githubusercontent.com/u/2149430?v=3","gravatar_id":"","url":"https://api.github.com/users/dati91","html_url":"https://github.com/dati91","followers_url":"https://api.github.com/users/dati91/followers","following_url":"https://api.github.com/users/dati91/following{/other_user}","gists_url":"https://api.github.com/users/dati91/gists{/gist_id}","starred_url":"https://api.github.com/users/dati91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dati91/subscriptions","organizations_url":"https://api.github.com/users/dati91/orgs","repos_url":"https://api.github.com/users/dati91/repos","events_url":"https://api.github.com/users/dati91/events{/privacy}","received_events_url":"https://api.github.com/users/dati91/received_events","type":"User","site_admin":false},"body":"it was too long for one line?","created_at":"2016-04-05T09:10:00Z","updated_at":"2016-04-05T09:10:01Z","html_url":"https://github.com/szeged/servo/pull/12#discussion_r58505869","pull_request_url":"https://api.github.com/repos/szeged/servo/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/szeged/servo/pulls/comments/58505869"},"html":{"href":"https://github.com/szeged/servo/pull/12#discussion_r58505869"},"pull_request":{"href":"https://api.github.com/repos/szeged/servo/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/szeged/servo/pulls/12","id":65143555,"html_url":"https://github.com/szeged/servo/pull/12","diff_url":"https://github.com/szeged/servo/pull/12.diff","patch_url":"https://github.com/szeged/servo/pull/12.patch","issue_url":"https://api.github.com/repos/szeged/servo/issues/12","number":12,"state":"open","locked":false,"title":"requestDevice options (filters and optoinalServices)","user":{"login":"zakorgy","id":11725775,"avatar_url":"https://avatars.githubusercontent.com/u/11725775?v=3","gravatar_id":"","url":"https://api.github.com/users/zakorgy","html_url":"https://github.com/zakorgy","followers_url":"https://api.github.com/users/zakorgy/followers","following_url":"https://api.github.com/users/zakorgy/following{/other_user}","gists_url":"https://api.github.com/users/zakorgy/gists{/gist_id}","starred_url":"https://api.github.com/users/zakorgy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zakorgy/subscriptions","organizations_url":"https://api.github.com/users/zakorgy/orgs","repos_url":"https://api.github.com/users/zakorgy/repos","events_url":"https://api.github.com/users/zakorgy/events{/privacy}","received_events_url":"https://api.github.com/users/zakorgy/received_events","type":"User","site_admin":false},"body":"some hints to test this code in console: \r\nhttps://gist.github.com/zakorgy/190e358da2d68fde3f0f65fe7156733d","created_at":"2016-04-04T13:19:17Z","updated_at":"2016-04-05T09:10:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5825426df73ee3e6af0190c0f1c507c3b459efca","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/szeged/servo/pulls/12/commits","review_comments_url":"https://api.github.com/repos/szeged/servo/pulls/12/comments","review_comment_url":"https://api.github.com/repos/szeged/servo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/szeged/servo/issues/12/comments","statuses_url":"https://api.github.com/repos/szeged/servo/statuses/3afa14fe23f3c8ab5cd7ccedc25f297d349c3771","head":{"label":"zakorgy:reqdevopts","ref":"reqdevopts","sha":"3afa14fe23f3c8ab5cd7ccedc25f297d349c3771","user":{"login":"zakorgy","id":11725775,"avatar_url":"https://avatars.githubusercontent.com/u/11725775?v=3","gravatar_id":"","url":"https://api.github.com/users/zakorgy","html_url":"https://github.com/zakorgy","followers_url":"https://api.github.com/users/zakorgy/followers","following_url":"https://api.github.com/users/zakorgy/following{/other_user}","gists_url":"https://api.github.com/users/zakorgy/gists{/gist_id}","starred_url":"https://api.github.com/users/zakorgy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zakorgy/subscriptions","organizations_url":"https://api.github.com/users/zakorgy/orgs","repos_url":"https://api.github.com/users/zakorgy/repos","events_url":"https://api.github.com/users/zakorgy/events{/privacy}","received_events_url":"https://api.github.com/users/zakorgy/received_events","type":"User","site_admin":false},"repo":{"id":53485776,"name":"servo","full_name":"zakorgy/servo","owner":{"login":"zakorgy","id":11725775,"avatar_url":"https://avatars.githubusercontent.com/u/11725775?v=3","gravatar_id":"","url":"https://api.github.com/users/zakorgy","html_url":"https://github.com/zakorgy","followers_url":"https://api.github.com/users/zakorgy/followers","following_url":"https://api.github.com/users/zakorgy/following{/other_user}","gists_url":"https://api.github.com/users/zakorgy/gists{/gist_id}","starred_url":"https://api.github.com/users/zakorgy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zakorgy/subscriptions","organizations_url":"https://api.github.com/users/zakorgy/orgs","repos_url":"https://api.github.com/users/zakorgy/repos","events_url":"https://api.github.com/users/zakorgy/events{/privacy}","received_events_url":"https://api.github.com/users/zakorgy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zakorgy/servo","description":"The Servo Browser Engine","fork":true,"url":"https://api.github.com/repos/zakorgy/servo","forks_url":"https://api.github.com/repos/zakorgy/servo/forks","keys_url":"https://api.github.com/repos/zakorgy/servo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zakorgy/servo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zakorgy/servo/teams","hooks_url":"https://api.github.com/repos/zakorgy/servo/hooks","issue_events_url":"https://api.github.com/repos/zakorgy/servo/issues/events{/number}","events_url":"https://api.github.com/repos/zakorgy/servo/events","assignees_url":"https://api.github.com/repos/zakorgy/servo/assignees{/user}","branches_url":"https://api.github.com/repos/zakorgy/servo/branches{/branch}","tags_url":"https://api.github.com/repos/zakorgy/servo/tags","blobs_url":"https://api.github.com/repos/zakorgy/servo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zakorgy/servo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zakorgy/servo/git/refs{/sha}","trees_url":"https://api.github.com/repos/zakorgy/servo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zakorgy/servo/statuses/{sha}","languages_url":"https://api.github.com/repos/zakorgy/servo/languages","stargazers_url":"https://api.github.com/repos/zakorgy/servo/stargazers","contributors_url":"https://api.github.com/repos/zakorgy/servo/contributors","subscribers_url":"https://api.github.com/repos/zakorgy/servo/subscribers","subscription_url":"https://api.github.com/repos/zakorgy/servo/subscription","commits_url":"https://api.github.com/repos/zakorgy/servo/commits{/sha}","git_commits_url":"https://api.github.com/repos/zakorgy/servo/git/commits{/sha}","comments_url":"https://api.github.com/repos/zakorgy/servo/comments{/number}","issue_comment_url":"https://api.github.com/repos/zakorgy/servo/issues/comments{/number}","contents_url":"https://api.github.com/repos/zakorgy/servo/contents/{+path}","compare_url":"https://api.github.com/repos/zakorgy/servo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zakorgy/servo/merges","archive_url":"https://api.github.com/repos/zakorgy/servo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zakorgy/servo/downloads","issues_url":"https://api.github.com/repos/zakorgy/servo/issues{/number}","pulls_url":"https://api.github.com/repos/zakorgy/servo/pulls{/number}","milestones_url":"https://api.github.com/repos/zakorgy/servo/milestones{/number}","notifications_url":"https://api.github.com/repos/zakorgy/servo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zakorgy/servo/labels{/name}","releases_url":"https://api.github.com/repos/zakorgy/servo/releases{/id}","deployments_url":"https://api.github.com/repos/zakorgy/servo/deployments","created_at":"2016-03-09T09:36:07Z","updated_at":"2016-01-25T13:06:41Z","pushed_at":"2016-04-05T05:54:13Z","git_url":"git://github.com/zakorgy/servo.git","ssh_url":"git@github.com:zakorgy/servo.git","clone_url":"https://github.com/zakorgy/servo.git","svn_url":"https://github.com/zakorgy/servo","homepage":"https://servo.org/","size":181726,"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":"szeged:bluetooth-ipc","ref":"bluetooth-ipc","sha":"2c35fbbf6abeac6a2d214d442db90f6a1ec79ad4","user":{"login":"szeged","id":1826696,"avatar_url":"https://avatars.githubusercontent.com/u/1826696?v=3","gravatar_id":"","url":"https://api.github.com/users/szeged","html_url":"https://github.com/szeged","followers_url":"https://api.github.com/users/szeged/followers","following_url":"https://api.github.com/users/szeged/following{/other_user}","gists_url":"https://api.github.com/users/szeged/gists{/gist_id}","starred_url":"https://api.github.com/users/szeged/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szeged/subscriptions","organizations_url":"https://api.github.com/users/szeged/orgs","repos_url":"https://api.github.com/users/szeged/repos","events_url":"https://api.github.com/users/szeged/events{/privacy}","received_events_url":"https://api.github.com/users/szeged/received_events","type":"Organization","site_admin":false},"repo":{"id":50353354,"name":"servo","full_name":"szeged/servo","owner":{"login":"szeged","id":1826696,"avatar_url":"https://avatars.githubusercontent.com/u/1826696?v=3","gravatar_id":"","url":"https://api.github.com/users/szeged","html_url":"https://github.com/szeged","followers_url":"https://api.github.com/users/szeged/followers","following_url":"https://api.github.com/users/szeged/following{/other_user}","gists_url":"https://api.github.com/users/szeged/gists{/gist_id}","starred_url":"https://api.github.com/users/szeged/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szeged/subscriptions","organizations_url":"https://api.github.com/users/szeged/orgs","repos_url":"https://api.github.com/users/szeged/repos","events_url":"https://api.github.com/users/szeged/events{/privacy}","received_events_url":"https://api.github.com/users/szeged/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/szeged/servo","description":"The Servo Browser Engine","fork":true,"url":"https://api.github.com/repos/szeged/servo","forks_url":"https://api.github.com/repos/szeged/servo/forks","keys_url":"https://api.github.com/repos/szeged/servo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/szeged/servo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/szeged/servo/teams","hooks_url":"https://api.github.com/repos/szeged/servo/hooks","issue_events_url":"https://api.github.com/repos/szeged/servo/issues/events{/number}","events_url":"https://api.github.com/repos/szeged/servo/events","assignees_url":"https://api.github.com/repos/szeged/servo/assignees{/user}","branches_url":"https://api.github.com/repos/szeged/servo/branches{/branch}","tags_url":"https://api.github.com/repos/szeged/servo/tags","blobs_url":"https://api.github.com/repos/szeged/servo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/szeged/servo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/szeged/servo/git/refs{/sha}","trees_url":"https://api.github.com/repos/szeged/servo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/szeged/servo/statuses/{sha}","languages_url":"https://api.github.com/repos/szeged/servo/languages","stargazers_url":"https://api.github.com/repos/szeged/servo/stargazers","contributors_url":"https://api.github.com/repos/szeged/servo/contributors","subscribers_url":"https://api.github.com/repos/szeged/servo/subscribers","subscription_url":"https://api.github.com/repos/szeged/servo/subscription","commits_url":"https://api.github.com/repos/szeged/servo/commits{/sha}","git_commits_url":"https://api.github.com/repos/szeged/servo/git/commits{/sha}","comments_url":"https://api.github.com/repos/szeged/servo/comments{/number}","issue_comment_url":"https://api.github.com/repos/szeged/servo/issues/comments{/number}","contents_url":"https://api.github.com/repos/szeged/servo/contents/{+path}","compare_url":"https://api.github.com/repos/szeged/servo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/szeged/servo/merges","archive_url":"https://api.github.com/repos/szeged/servo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/szeged/servo/downloads","issues_url":"https://api.github.com/repos/szeged/servo/issues{/number}","pulls_url":"https://api.github.com/repos/szeged/servo/pulls{/number}","milestones_url":"https://api.github.com/repos/szeged/servo/milestones{/number}","notifications_url":"https://api.github.com/repos/szeged/servo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/szeged/servo/labels{/name}","releases_url":"https://api.github.com/repos/szeged/servo/releases{/id}","deployments_url":"https://api.github.com/repos/szeged/servo/deployments","created_at":"2016-01-25T13:48:48Z","updated_at":"2016-01-25T13:06:41Z","pushed_at":"2016-04-05T07:50:03Z","git_url":"git://github.com/szeged/servo.git","ssh_url":"git@github.com:szeged/servo.git","clone_url":"https://github.com/szeged/servo.git","svn_url":"https://github.com/szeged/servo","homepage":"https://servo.org/","size":178792,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/szeged/servo/pulls/12"},"html":{"href":"https://github.com/szeged/servo/pull/12"},"issue":{"href":"https://api.github.com/repos/szeged/servo/issues/12"},"comments":{"href":"https://api.github.com/repos/szeged/servo/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/szeged/servo/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/szeged/servo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/szeged/servo/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/szeged/servo/statuses/3afa14fe23f3c8ab5cd7ccedc25f297d349c3771"}}}}