1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979
// // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIUrlClassifierDBService.idl // /// `interface nsIUrlClassifierCallback : nsISupports` /// // The actual type definition for the interface. This struct has methods // declared on it which will call through its vtable. You never want to pass // this type around by value, always pass it behind a reference. #[repr(C)] pub struct nsIUrlClassifierCallback { vtable: *const nsIUrlClassifierCallbackVTable, /// This field is a phantomdata to ensure that the VTable type and any /// struct containing it is not safe to send across threads, as XPCOM is /// generally not threadsafe. /// /// XPCOM interfaces in general are not safe to send across threads. __nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>, } // Implementing XpCom for an interface exposes its IID, which allows for easy // use of the `.query_interface<T>` helper method. This also defines that // method for nsIUrlClassifierCallback. unsafe impl XpCom for nsIUrlClassifierCallback { const IID: nsIID = nsID(0x4ca27b6b, 0xa674, 0x4b3d, [0xab, 0x30, 0xd2, 0x1e, 0x2d, 0xa2, 0xdf, 0xfb]); } // We need to implement the RefCounted trait so we can be used with `RefPtr`. // This trait teaches `RefPtr` how to manage our memory. unsafe impl RefCounted for nsIUrlClassifierCallback { #[inline] unsafe fn addref(&self) { self.AddRef(); } #[inline] unsafe fn release(&self) { self.Release(); } } // This trait is implemented on all types which can be coerced to from nsIUrlClassifierCallback. // It is used in the implementation of `fn coerce<T>`. We hide it from the // documentation, because it clutters it up a lot. #[doc(hidden)] pub trait nsIUrlClassifierCallbackCoerce { /// Cheaply cast a value of this type from a `nsIUrlClassifierCallback`. fn coerce_from(v: &nsIUrlClassifierCallback) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIUrlClassifierCallbackCoerce for nsIUrlClassifierCallback { #[inline] fn coerce_from(v: &nsIUrlClassifierCallback) -> &Self { v } } impl nsIUrlClassifierCallback { /// Cast this `nsIUrlClassifierCallback` to one of its base interfaces. #[inline] pub fn coerce<T: nsIUrlClassifierCallbackCoerce>(&self) -> &T { T::coerce_from(self) } } // Every interface struct type implements `Deref` to its base interface. This // causes methods on the base interfaces to be directly avaliable on the // object. For example, you can call `.AddRef` or `.QueryInterface` directly // on any interface which inherits from `nsISupports`. impl ::std::ops::Deref for nsIUrlClassifierCallback { type Target = nsISupports; #[inline] fn deref(&self) -> &nsISupports { unsafe { ::std::mem::transmute(self) } } } // Ensure we can use .coerce() to cast to our base types as well. Any type which // our base interface can coerce from should be coercable from us as well. impl<T: nsISupportsCoerce> nsIUrlClassifierCallbackCoerce for T { #[inline] fn coerce_from(v: &nsIUrlClassifierCallback) -> &Self { T::coerce_from(v) } } // This struct represents the interface's VTable. A pointer to a statically // allocated version of this struct is at the beginning of every nsIUrlClassifierCallback // object. It contains one pointer field for each method in the interface. In // the case where we can't generate a binding for a method, we include a void // pointer. #[doc(hidden)] #[repr(C)] pub struct nsIUrlClassifierCallbackVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* void handleEvent (in ACString value); */ pub HandleEvent: unsafe extern "system" fn (this: *const nsIUrlClassifierCallback, value: &::nsstring::nsACString) -> nsresult, } // The implementations of the function wrappers which are exposed to rust code. // Call these methods rather than manually calling through the VTable struct. impl nsIUrlClassifierCallback { /// `void handleEvent (in ACString value);` #[inline] pub unsafe fn HandleEvent(&self, value: &::nsstring::nsACString) -> nsresult { ((*self.vtable).HandleEvent)(self, value) } } /// `interface nsIUrlClassifierUpdateObserver : nsISupports` /// /// ```text /// /** /// * The nsIUrlClassifierUpdateObserver interface is implemented by /// * clients streaming updates to the url-classifier (usually /// * nsUrlClassifierStreamUpdater. /// */ /// ``` /// // The actual type definition for the interface. This struct has methods // declared on it which will call through its vtable. You never want to pass // this type around by value, always pass it behind a reference. #[repr(C)] pub struct nsIUrlClassifierUpdateObserver { vtable: *const nsIUrlClassifierUpdateObserverVTable, /// This field is a phantomdata to ensure that the VTable type and any /// struct containing it is not safe to send across threads, as XPCOM is /// generally not threadsafe. /// /// XPCOM interfaces in general are not safe to send across threads. __nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>, } // Implementing XpCom for an interface exposes its IID, which allows for easy // use of the `.query_interface<T>` helper method. This also defines that // method for nsIUrlClassifierUpdateObserver. unsafe impl XpCom for nsIUrlClassifierUpdateObserver { const IID: nsIID = nsID(0x9fa11561, 0x5816, 0x4e1b, [0xbc, 0xc9, 0xb6, 0x29, 0xca, 0x05, 0xcc, 0xe6]); } // We need to implement the RefCounted trait so we can be used with `RefPtr`. // This trait teaches `RefPtr` how to manage our memory. unsafe impl RefCounted for nsIUrlClassifierUpdateObserver { #[inline] unsafe fn addref(&self) { self.AddRef(); } #[inline] unsafe fn release(&self) { self.Release(); } } // This trait is implemented on all types which can be coerced to from nsIUrlClassifierUpdateObserver. // It is used in the implementation of `fn coerce<T>`. We hide it from the // documentation, because it clutters it up a lot. #[doc(hidden)] pub trait nsIUrlClassifierUpdateObserverCoerce { /// Cheaply cast a value of this type from a `nsIUrlClassifierUpdateObserver`. fn coerce_from(v: &nsIUrlClassifierUpdateObserver) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIUrlClassifierUpdateObserverCoerce for nsIUrlClassifierUpdateObserver { #[inline] fn coerce_from(v: &nsIUrlClassifierUpdateObserver) -> &Self { v } } impl nsIUrlClassifierUpdateObserver { /// Cast this `nsIUrlClassifierUpdateObserver` to one of its base interfaces. #[inline] pub fn coerce<T: nsIUrlClassifierUpdateObserverCoerce>(&self) -> &T { T::coerce_from(self) } } // Every interface struct type implements `Deref` to its base interface. This // causes methods on the base interfaces to be directly avaliable on the // object. For example, you can call `.AddRef` or `.QueryInterface` directly // on any interface which inherits from `nsISupports`. impl ::std::ops::Deref for nsIUrlClassifierUpdateObserver { type Target = nsISupports; #[inline] fn deref(&self) -> &nsISupports { unsafe { ::std::mem::transmute(self) } } } // Ensure we can use .coerce() to cast to our base types as well. Any type which // our base interface can coerce from should be coercable from us as well. impl<T: nsISupportsCoerce> nsIUrlClassifierUpdateObserverCoerce for T { #[inline] fn coerce_from(v: &nsIUrlClassifierUpdateObserver) -> &Self { T::coerce_from(v) } } // This struct represents the interface's VTable. A pointer to a statically // allocated version of this struct is at the beginning of every nsIUrlClassifierUpdateObserver // object. It contains one pointer field for each method in the interface. In // the case where we can't generate a binding for a method, we include a void // pointer. #[doc(hidden)] #[repr(C)] pub struct nsIUrlClassifierUpdateObserverVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* void updateUrlRequested (in ACString url, in ACString table); */ pub UpdateUrlRequested: unsafe extern "system" fn (this: *const nsIUrlClassifierUpdateObserver, url: &::nsstring::nsACString, table: &::nsstring::nsACString) -> nsresult, /* void streamFinished (in nsresult status, in unsigned long delay); */ pub StreamFinished: unsafe extern "system" fn (this: *const nsIUrlClassifierUpdateObserver, status: nsresult, delay: libc::uint32_t) -> nsresult, /* void updateError (in nsresult error); */ pub UpdateError: unsafe extern "system" fn (this: *const nsIUrlClassifierUpdateObserver, error: nsresult) -> nsresult, /* void updateSuccess (in unsigned long requestedTimeout); */ pub UpdateSuccess: unsafe extern "system" fn (this: *const nsIUrlClassifierUpdateObserver, requestedTimeout: libc::uint32_t) -> nsresult, } // The implementations of the function wrappers which are exposed to rust code. // Call these methods rather than manually calling through the VTable struct. impl nsIUrlClassifierUpdateObserver { /// ```text /// /** /// * The update requested a new URL whose contents should be downloaded /// * and sent to the classifier as a new stream. /// * /// * @param url The url that was requested. /// * @param table The table name that this URL's contents will be associated /// * with. This should be passed back to beginStream(). /// */ /// ``` /// /// `void updateUrlRequested (in ACString url, in ACString table);` #[inline] pub unsafe fn UpdateUrlRequested(&self, url: &::nsstring::nsACString, table: &::nsstring::nsACString) -> nsresult { ((*self.vtable).UpdateUrlRequested)(self, url, table) } /// ```text /// /** /// * A stream update has completed. /// * /// * @param status The state of the update process. /// * @param delay The amount of time the updater should wait to fetch the /// * next URL in ms. /// */ /// ``` /// /// `void streamFinished (in nsresult status, in unsigned long delay);` #[inline] pub unsafe fn StreamFinished(&self, status: nsresult, delay: libc::uint32_t) -> nsresult { ((*self.vtable).StreamFinished)(self, status, delay) } /// `void updateError (in nsresult error);` #[inline] pub unsafe fn UpdateError(&self, error: nsresult) -> nsresult { ((*self.vtable).UpdateError)(self, error) } /// ```text /// /** /// * The update has completed successfully. /// * /// * @param requestedTimeout The number of seconds that the caller should /// * wait before trying to update again. /// **/ /// ``` /// /// `void updateSuccess (in unsigned long requestedTimeout);` #[inline] pub unsafe fn UpdateSuccess(&self, requestedTimeout: libc::uint32_t) -> nsresult { ((*self.vtable).UpdateSuccess)(self, requestedTimeout) } } /// `interface nsIUrlClassifierDBService : nsISupports` /// /// ```text /// /** /// * This is a proxy class that is instantiated and called from the JS thread. /// * It provides async methods for querying and updating the database. As the /// * methods complete, they call the callback function. /// */ /// ``` /// // The actual type definition for the interface. This struct has methods // declared on it which will call through its vtable. You never want to pass // this type around by value, always pass it behind a reference. #[repr(C)] pub struct nsIUrlClassifierDBService { vtable: *const nsIUrlClassifierDBServiceVTable, /// This field is a phantomdata to ensure that the VTable type and any /// struct containing it is not safe to send across threads, as XPCOM is /// generally not threadsafe. /// /// XPCOM interfaces in general are not safe to send across threads. __nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>, } // Implementing XpCom for an interface exposes its IID, which allows for easy // use of the `.query_interface<T>` helper method. This also defines that // method for nsIUrlClassifierDBService. unsafe impl XpCom for nsIUrlClassifierDBService { const IID: nsIID = nsID(0x7a258022, 0x6765, 0x11e5, [0xb3, 0x79, 0xb3, 0x7b, 0x1f, 0x23, 0x54, 0xbe]); } // We need to implement the RefCounted trait so we can be used with `RefPtr`. // This trait teaches `RefPtr` how to manage our memory. unsafe impl RefCounted for nsIUrlClassifierDBService { #[inline] unsafe fn addref(&self) { self.AddRef(); } #[inline] unsafe fn release(&self) { self.Release(); } } // This trait is implemented on all types which can be coerced to from nsIUrlClassifierDBService. // It is used in the implementation of `fn coerce<T>`. We hide it from the // documentation, because it clutters it up a lot. #[doc(hidden)] pub trait nsIUrlClassifierDBServiceCoerce { /// Cheaply cast a value of this type from a `nsIUrlClassifierDBService`. fn coerce_from(v: &nsIUrlClassifierDBService) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIUrlClassifierDBServiceCoerce for nsIUrlClassifierDBService { #[inline] fn coerce_from(v: &nsIUrlClassifierDBService) -> &Self { v } } impl nsIUrlClassifierDBService { /// Cast this `nsIUrlClassifierDBService` to one of its base interfaces. #[inline] pub fn coerce<T: nsIUrlClassifierDBServiceCoerce>(&self) -> &T { T::coerce_from(self) } } // Every interface struct type implements `Deref` to its base interface. This // causes methods on the base interfaces to be directly avaliable on the // object. For example, you can call `.AddRef` or `.QueryInterface` directly // on any interface which inherits from `nsISupports`. impl ::std::ops::Deref for nsIUrlClassifierDBService { type Target = nsISupports; #[inline] fn deref(&self) -> &nsISupports { unsafe { ::std::mem::transmute(self) } } } // Ensure we can use .coerce() to cast to our base types as well. Any type which // our base interface can coerce from should be coercable from us as well. impl<T: nsISupportsCoerce> nsIUrlClassifierDBServiceCoerce for T { #[inline] fn coerce_from(v: &nsIUrlClassifierDBService) -> &Self { T::coerce_from(v) } } // This struct represents the interface's VTable. A pointer to a statically // allocated version of this struct is at the beginning of every nsIUrlClassifierDBService // object. It contains one pointer field for each method in the interface. In // the case where we can't generate a binding for a method, we include a void // pointer. #[doc(hidden)] #[repr(C)] pub struct nsIUrlClassifierDBServiceVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* void lookup (in nsIPrincipal principal, in ACString tables, in nsIUrlClassifierCallback c); */ pub Lookup: unsafe extern "system" fn (this: *const nsIUrlClassifierDBService, principal: *const nsIPrincipal, tables: &::nsstring::nsACString, c: *const nsIUrlClassifierCallback) -> nsresult, /* void getTables (in nsIUrlClassifierCallback c); */ pub GetTables: unsafe extern "system" fn (this: *const nsIUrlClassifierDBService, c: *const nsIUrlClassifierCallback) -> nsresult, /* void setHashCompleter (in ACString tableName, in nsIUrlClassifierHashCompleter completer); */ pub SetHashCompleter: unsafe extern "system" fn (this: *const nsIUrlClassifierDBService, tableName: &::nsstring::nsACString, completer: *const nsIUrlClassifierHashCompleter) -> nsresult, /* void clearLastResults (); */ pub ClearLastResults: unsafe extern "system" fn (this: *const nsIUrlClassifierDBService) -> nsresult, /* void beginUpdate (in nsIUrlClassifierUpdateObserver updater, in ACString tables); */ pub BeginUpdate: unsafe extern "system" fn (this: *const nsIUrlClassifierDBService, updater: *const nsIUrlClassifierUpdateObserver, tables: &::nsstring::nsACString) -> nsresult, /* void beginStream (in ACString table); */ pub BeginStream: unsafe extern "system" fn (this: *const nsIUrlClassifierDBService, table: &::nsstring::nsACString) -> nsresult, /* void updateStream (in ACString updateChunk); */ pub UpdateStream: unsafe extern "system" fn (this: *const nsIUrlClassifierDBService, updateChunk: &::nsstring::nsACString) -> nsresult, /* void finishStream (); */ pub FinishStream: unsafe extern "system" fn (this: *const nsIUrlClassifierDBService) -> nsresult, /* void finishUpdate (); */ pub FinishUpdate: unsafe extern "system" fn (this: *const nsIUrlClassifierDBService) -> nsresult, /* void cancelUpdate (); */ pub CancelUpdate: unsafe extern "system" fn (this: *const nsIUrlClassifierDBService) -> nsresult, /* void resetDatabase (); */ pub ResetDatabase: unsafe extern "system" fn (this: *const nsIUrlClassifierDBService) -> nsresult, /* void reloadDatabase (); */ pub ReloadDatabase: unsafe extern "system" fn (this: *const nsIUrlClassifierDBService) -> nsresult, /* void clearCache (); */ pub ClearCache: unsafe extern "system" fn (this: *const nsIUrlClassifierDBService) -> nsresult, } // The implementations of the function wrappers which are exposed to rust code. // Call these methods rather than manually calling through the VTable struct. impl nsIUrlClassifierDBService { /// ```text /// /** /// * Looks up a URI in the specified tables. /// * /// * @param principal: The principal containing the URI to search. /// * @param c: The callback will be called with a comma-separated list /// * of tables to which the key belongs. /// */ /// ``` /// /// `void lookup (in nsIPrincipal principal, in ACString tables, in nsIUrlClassifierCallback c);` #[inline] pub unsafe fn Lookup(&self, principal: *const nsIPrincipal, tables: &::nsstring::nsACString, c: *const nsIUrlClassifierCallback) -> nsresult { ((*self.vtable).Lookup)(self, principal, tables, c) } /// ```text /// /** /// * Lists the tables along with their meta info in the following format: /// * /// * tablename;[metadata]\n /// * tablename2;[metadata]\n /// * /// * For v2 tables, the metadata is the chunks info such as /// * /// * goog-phish-shavar;a:10,14,30-40s:56,67 /// * goog-unwanted-shavar;a:1-3,5 /// * /// * For v4 tables, base64 encoded state is currently the only info in the /// * metadata (can be extended whenever necessary). For exmaple, /// * /// * goog-phish-proto;Cg0IARAGGAEiAzAwMTABEKqTARoCGAjT1gDD:oCGAjT1gDD\n /// * goog-malware-proto;Cg0IAhAGGAEiAzAwMTABENCQARoCGAjx5Yty:BENCQARoCGAj\n /// * /// * Note that the metadata is colon-separated. /// * /// */ /// ``` /// /// `void getTables (in nsIUrlClassifierCallback c);` #[inline] pub unsafe fn GetTables(&self, c: *const nsIUrlClassifierCallback) -> nsresult { ((*self.vtable).GetTables)(self, c) } /// ```text /// /** /// * Set the nsIUrlClassifierCompleter object for a given table. This /// * object will be used to request complete versions of partial /// * hashes. /// */ /// ``` /// /// `void setHashCompleter (in ACString tableName, in nsIUrlClassifierHashCompleter completer);` #[inline] pub unsafe fn SetHashCompleter(&self, tableName: &::nsstring::nsACString, completer: *const nsIUrlClassifierHashCompleter) -> nsresult { ((*self.vtable).SetHashCompleter)(self, tableName, completer) } /// ```text /// /** /// * Forget the results that were used in the last DB update. /// */ /// ``` /// /// `void clearLastResults ();` #[inline] pub unsafe fn ClearLastResults(&self, ) -> nsresult { ((*self.vtable).ClearLastResults)(self, ) } /// ```text /// /** /// * Begin an update process. Will throw NS_ERROR_NOT_AVAILABLE if there /// * is already an update in progress. /// * /// * @param updater The update observer tied to this update. /// * @param tables A comma-separated list of tables included in this update. /// */ /// ``` /// /// `void beginUpdate (in nsIUrlClassifierUpdateObserver updater, in ACString tables);` #[inline] pub unsafe fn BeginUpdate(&self, updater: *const nsIUrlClassifierUpdateObserver, tables: &::nsstring::nsACString) -> nsresult { ((*self.vtable).BeginUpdate)(self, updater, tables) } /// ```text /// /** /// * Begin a stream update. This should be called once per url being /// * fetched. /// * /// * @param table The table the contents of this stream will be associated /// * with, or empty for the initial stream. /// */ /// ``` /// /// `void beginStream (in ACString table);` #[inline] pub unsafe fn BeginStream(&self, table: &::nsstring::nsACString) -> nsresult { ((*self.vtable).BeginStream)(self, table) } /// ```text /// /** /// * Update the table incrementally. /// */ /// ``` /// /// `void updateStream (in ACString updateChunk);` #[inline] pub unsafe fn UpdateStream(&self, updateChunk: &::nsstring::nsACString) -> nsresult { ((*self.vtable).UpdateStream)(self, updateChunk) } /// ```text /// /** /// * Finish an individual stream update. Must be called for every /// * beginStream() call, before the next beginStream() or finishUpdate(). /// * /// * The update observer's streamFinished will be called once the /// * stream has been processed. /// */ /// ``` /// /// `void finishStream ();` #[inline] pub unsafe fn FinishStream(&self, ) -> nsresult { ((*self.vtable).FinishStream)(self, ) } /// ```text /// /** /// * Finish an incremental update. This will attempt to commit any /// * pending changes and resets the update interface. /// * /// * The update observer's updateSucceeded or updateError methods /// * will be called when the update has been processed. /// */ /// ``` /// /// `void finishUpdate ();` #[inline] pub unsafe fn FinishUpdate(&self, ) -> nsresult { ((*self.vtable).FinishUpdate)(self, ) } /// ```text /// /** /// * Cancel an incremental update. This rolls back any pending changes. /// * and resets the update interface. /// * /// * The update observer's updateError method will be called when the /// * update has been rolled back. /// */ /// ``` /// /// `void cancelUpdate ();` #[inline] pub unsafe fn CancelUpdate(&self, ) -> nsresult { ((*self.vtable).CancelUpdate)(self, ) } /// ```text /// /** /// * Reset the url-classifier database. This call will delete the existing /// * database, emptying all tables. Mostly intended for use in unit tests. /// */ /// ``` /// /// `void resetDatabase ();` #[inline] pub unsafe fn ResetDatabase(&self, ) -> nsresult { ((*self.vtable).ResetDatabase)(self, ) } /// ```text /// /** /// * Reload he url-classifier database. This will empty all cache for /// * completions from gethash, and reload it from database. Mostly intended /// * for use in tests. /// */ /// ``` /// /// `void reloadDatabase ();` #[inline] pub unsafe fn ReloadDatabase(&self, ) -> nsresult { ((*self.vtable).ReloadDatabase)(self, ) } /// ```text /// /** /// * Empty all the caches. /// */ /// ``` /// /// `void clearCache ();` #[inline] pub unsafe fn ClearCache(&self, ) -> nsresult { ((*self.vtable).ClearCache)(self, ) } } /// `interface nsIUrlClassifierLookupCallback : nsISupports` /// /// ```text /// /** /// * This is an internal helper interface for communication between the /// * main thread and the dbservice worker thread. It is called for each /// * lookup to provide a set of possible results, which the main thread /// * may need to expand using an nsIUrlClassifierCompleter. /// */ /// ``` /// // The actual type definition for the interface. This struct has methods // declared on it which will call through its vtable. You never want to pass // this type around by value, always pass it behind a reference. #[repr(C)] pub struct nsIUrlClassifierLookupCallback { vtable: *const nsIUrlClassifierLookupCallbackVTable, /// This field is a phantomdata to ensure that the VTable type and any /// struct containing it is not safe to send across threads, as XPCOM is /// generally not threadsafe. /// /// XPCOM interfaces in general are not safe to send across threads. __nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>, } // Implementing XpCom for an interface exposes its IID, which allows for easy // use of the `.query_interface<T>` helper method. This also defines that // method for nsIUrlClassifierLookupCallback. unsafe impl XpCom for nsIUrlClassifierLookupCallback { const IID: nsIID = nsID(0xb903dc8f, 0xdff1, 0x42fe, [0x89, 0x4b, 0x36, 0xe7, 0xa5, 0x9b, 0xb8, 0x01]); } // We need to implement the RefCounted trait so we can be used with `RefPtr`. // This trait teaches `RefPtr` how to manage our memory. unsafe impl RefCounted for nsIUrlClassifierLookupCallback { #[inline] unsafe fn addref(&self) { self.AddRef(); } #[inline] unsafe fn release(&self) { self.Release(); } } // This trait is implemented on all types which can be coerced to from nsIUrlClassifierLookupCallback. // It is used in the implementation of `fn coerce<T>`. We hide it from the // documentation, because it clutters it up a lot. #[doc(hidden)] pub trait nsIUrlClassifierLookupCallbackCoerce { /// Cheaply cast a value of this type from a `nsIUrlClassifierLookupCallback`. fn coerce_from(v: &nsIUrlClassifierLookupCallback) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIUrlClassifierLookupCallbackCoerce for nsIUrlClassifierLookupCallback { #[inline] fn coerce_from(v: &nsIUrlClassifierLookupCallback) -> &Self { v } } impl nsIUrlClassifierLookupCallback { /// Cast this `nsIUrlClassifierLookupCallback` to one of its base interfaces. #[inline] pub fn coerce<T: nsIUrlClassifierLookupCallbackCoerce>(&self) -> &T { T::coerce_from(self) } } // Every interface struct type implements `Deref` to its base interface. This // causes methods on the base interfaces to be directly avaliable on the // object. For example, you can call `.AddRef` or `.QueryInterface` directly // on any interface which inherits from `nsISupports`. impl ::std::ops::Deref for nsIUrlClassifierLookupCallback { type Target = nsISupports; #[inline] fn deref(&self) -> &nsISupports { unsafe { ::std::mem::transmute(self) } } } // Ensure we can use .coerce() to cast to our base types as well. Any type which // our base interface can coerce from should be coercable from us as well. impl<T: nsISupportsCoerce> nsIUrlClassifierLookupCallbackCoerce for T { #[inline] fn coerce_from(v: &nsIUrlClassifierLookupCallback) -> &Self { T::coerce_from(v) } } // This struct represents the interface's VTable. A pointer to a statically // allocated version of this struct is at the beginning of every nsIUrlClassifierLookupCallback // object. It contains one pointer field for each method in the interface. In // the case where we can't generate a binding for a method, we include a void // pointer. #[doc(hidden)] #[repr(C)] pub struct nsIUrlClassifierLookupCallbackVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* void lookupComplete (in ResultArray results); */ /// Unable to generate binding because `native type nsTArray<mozilla::safebrowsing::LookupResult> is unsupported` pub LookupComplete: *const ::libc::c_void, } // The implementations of the function wrappers which are exposed to rust code. // Call these methods rather than manually calling through the VTable struct. impl nsIUrlClassifierLookupCallback { /// ```text /// /** /// * The lookup process is complete. /// * /// * @param results /// * If this parameter is null, there were no results found. /// * If not, it contains an array of nsUrlClassifierEntry objects /// * with possible matches. The callee is responsible for freeing /// * this array. /// */ /// ``` /// /// `void lookupComplete (in ResultArray results);` const _LookupComplete: () = (); } /// `interface nsIUrlClassifierClassifyCallback : nsISupports` /// /// ```text /// /** /// * This is an internal helper interface which is called after each /// * classify completes to provide and handle a set of possible results, /// * which the main thread may need to expand using an nsIURIClassifierCallback. /// */ /// ``` /// // The actual type definition for the interface. This struct has methods // declared on it which will call through its vtable. You never want to pass // this type around by value, always pass it behind a reference. #[repr(C)] pub struct nsIUrlClassifierClassifyCallback { vtable: *const nsIUrlClassifierClassifyCallbackVTable, /// This field is a phantomdata to ensure that the VTable type and any /// struct containing it is not safe to send across threads, as XPCOM is /// generally not threadsafe. /// /// XPCOM interfaces in general are not safe to send across threads. __nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>, } // Implementing XpCom for an interface exposes its IID, which allows for easy // use of the `.query_interface<T>` helper method. This also defines that // method for nsIUrlClassifierClassifyCallback. unsafe impl XpCom for nsIUrlClassifierClassifyCallback { const IID: nsIID = nsID(0x091adf98, 0x28a5, 0x473d, [0x8d, 0xec, 0x5b, 0x34, 0xb4, 0xe6, 0x24, 0x96]); } // We need to implement the RefCounted trait so we can be used with `RefPtr`. // This trait teaches `RefPtr` how to manage our memory. unsafe impl RefCounted for nsIUrlClassifierClassifyCallback { #[inline] unsafe fn addref(&self) { self.AddRef(); } #[inline] unsafe fn release(&self) { self.Release(); } } // This trait is implemented on all types which can be coerced to from nsIUrlClassifierClassifyCallback. // It is used in the implementation of `fn coerce<T>`. We hide it from the // documentation, because it clutters it up a lot. #[doc(hidden)] pub trait nsIUrlClassifierClassifyCallbackCoerce { /// Cheaply cast a value of this type from a `nsIUrlClassifierClassifyCallback`. fn coerce_from(v: &nsIUrlClassifierClassifyCallback) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIUrlClassifierClassifyCallbackCoerce for nsIUrlClassifierClassifyCallback { #[inline] fn coerce_from(v: &nsIUrlClassifierClassifyCallback) -> &Self { v } } impl nsIUrlClassifierClassifyCallback { /// Cast this `nsIUrlClassifierClassifyCallback` to one of its base interfaces. #[inline] pub fn coerce<T: nsIUrlClassifierClassifyCallbackCoerce>(&self) -> &T { T::coerce_from(self) } } // Every interface struct type implements `Deref` to its base interface. This // causes methods on the base interfaces to be directly avaliable on the // object. For example, you can call `.AddRef` or `.QueryInterface` directly // on any interface which inherits from `nsISupports`. impl ::std::ops::Deref for nsIUrlClassifierClassifyCallback { type Target = nsISupports; #[inline] fn deref(&self) -> &nsISupports { unsafe { ::std::mem::transmute(self) } } } // Ensure we can use .coerce() to cast to our base types as well. Any type which // our base interface can coerce from should be coercable from us as well. impl<T: nsISupportsCoerce> nsIUrlClassifierClassifyCallbackCoerce for T { #[inline] fn coerce_from(v: &nsIUrlClassifierClassifyCallback) -> &Self { T::coerce_from(v) } } // This struct represents the interface's VTable. A pointer to a statically // allocated version of this struct is at the beginning of every nsIUrlClassifierClassifyCallback // object. It contains one pointer field for each method in the interface. In // the case where we can't generate a binding for a method, we include a void // pointer. #[doc(hidden)] #[repr(C)] pub struct nsIUrlClassifierClassifyCallbackVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* void handleResult (in ACString aList, in ACString aPrefix); */ pub HandleResult: unsafe extern "system" fn (this: *const nsIUrlClassifierClassifyCallback, aList: &::nsstring::nsACString, aPrefix: &::nsstring::nsACString) -> nsresult, } // The implementations of the function wrappers which are exposed to rust code. // Call these methods rather than manually calling through the VTable struct. impl nsIUrlClassifierClassifyCallback { /// ```text /// /** /// * The function is called each time the URL matches a Safe Browsing list /// * The function could be called multiple times if URL matches multiple lists /// * /// */ /// ``` /// /// `void handleResult (in ACString aList, in ACString aPrefix);` #[inline] pub unsafe fn HandleResult(&self, aList: &::nsstring::nsACString, aPrefix: &::nsstring::nsACString) -> nsresult { ((*self.vtable).HandleResult)(self, aList, aPrefix) } }