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
// // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIAsyncShutdown.idl // /// `interface nsIAsyncShutdownBlocker : nsISupports` /// /// ```text /// /** /// * A blocker installed by a client to be informed during some stage of /// * shutdown and block shutdown asynchronously until some condition is /// * complete. /// * /// * If you wish to use AsyncShutdown, you will need to implement this /// * interface (and only this interface). /// */ /// ``` /// // 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 nsIAsyncShutdownBlocker { vtable: *const nsIAsyncShutdownBlockerVTable, /// 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 nsIAsyncShutdownBlocker. unsafe impl XpCom for nsIAsyncShutdownBlocker { const IID: nsIID = nsID(0x4ef43f29, 0x6715, 0x4b57, [0xa7, 0x50, 0x2f, 0xf8, 0x36, 0x95, 0xdd, 0xce]); } // 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 nsIAsyncShutdownBlocker { #[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 nsIAsyncShutdownBlocker. // 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 nsIAsyncShutdownBlockerCoerce { /// Cheaply cast a value of this type from a `nsIAsyncShutdownBlocker`. fn coerce_from(v: &nsIAsyncShutdownBlocker) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIAsyncShutdownBlockerCoerce for nsIAsyncShutdownBlocker { #[inline] fn coerce_from(v: &nsIAsyncShutdownBlocker) -> &Self { v } } impl nsIAsyncShutdownBlocker { /// Cast this `nsIAsyncShutdownBlocker` to one of its base interfaces. #[inline] pub fn coerce<T: nsIAsyncShutdownBlockerCoerce>(&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 nsIAsyncShutdownBlocker { 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> nsIAsyncShutdownBlockerCoerce for T { #[inline] fn coerce_from(v: &nsIAsyncShutdownBlocker) -> &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 nsIAsyncShutdownBlocker // 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 nsIAsyncShutdownBlockerVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* readonly attribute AString name; */ pub GetName: unsafe extern "system" fn (this: *const nsIAsyncShutdownBlocker, aName: &mut ::nsstring::nsAString) -> nsresult, /* void blockShutdown (in nsIAsyncShutdownClient aBarrierClient); */ pub BlockShutdown: unsafe extern "system" fn (this: *const nsIAsyncShutdownBlocker, aBarrierClient: *const nsIAsyncShutdownClient) -> nsresult, /* readonly attribute nsIPropertyBag state; */ pub GetState: unsafe extern "system" fn (this: *const nsIAsyncShutdownBlocker, aState: *mut *const nsIPropertyBag) -> 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 nsIAsyncShutdownBlocker { /// ```text /// /** /// * The *unique* name of the blocker. /// * /// * By convention, it should respect the following format: /// * "MyModuleName: Doing something while it's time" /// * e.g. /// * "OS.File: Flushing before profile-before-change" /// * /// * This attribute is uploaded as part of crash reports. /// */ /// ``` /// /// `readonly attribute AString name;` #[inline] pub unsafe fn GetName(&self, aName: &mut ::nsstring::nsAString) -> nsresult { ((*self.vtable).GetName)(self, aName) } /// ```text /// /** /// * Inform the blocker that the stage of shutdown has started. /// * Shutdown will NOT proceed until `aBarrierClient.removeBlocker(this)` /// * has been called. /// */ /// ``` /// /// `void blockShutdown (in nsIAsyncShutdownClient aBarrierClient);` #[inline] pub unsafe fn BlockShutdown(&self, aBarrierClient: *const nsIAsyncShutdownClient) -> nsresult { ((*self.vtable).BlockShutdown)(self, aBarrierClient) } /// ```text /// /** /// * The current state of the blocker. /// * /// * In case of crash, this is converted to JSON and attached to /// * the crash report. /// * /// * This field may be used to provide JSON-style data structures. /// * For this purpose, use /// * - nsIPropertyBag to represent objects; /// * - nsIVariant to represent field values (which may hold nsIPropertyBag /// * themselves). /// */ /// ``` /// /// `readonly attribute nsIPropertyBag state;` #[inline] pub unsafe fn GetState(&self, aState: *mut *const nsIPropertyBag) -> nsresult { ((*self.vtable).GetState)(self, aState) } } /// `interface nsIAsyncShutdownClient : 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 nsIAsyncShutdownClient { vtable: *const nsIAsyncShutdownClientVTable, /// 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 nsIAsyncShutdownClient. unsafe impl XpCom for nsIAsyncShutdownClient { const IID: nsIID = nsID(0xd2031049, 0xb990, 0x43a2, [0x95, 0xbe, 0x59, 0xf8, 0xa3, 0xca, 0x59, 0x54]); } // 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 nsIAsyncShutdownClient { #[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 nsIAsyncShutdownClient. // 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 nsIAsyncShutdownClientCoerce { /// Cheaply cast a value of this type from a `nsIAsyncShutdownClient`. fn coerce_from(v: &nsIAsyncShutdownClient) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIAsyncShutdownClientCoerce for nsIAsyncShutdownClient { #[inline] fn coerce_from(v: &nsIAsyncShutdownClient) -> &Self { v } } impl nsIAsyncShutdownClient { /// Cast this `nsIAsyncShutdownClient` to one of its base interfaces. #[inline] pub fn coerce<T: nsIAsyncShutdownClientCoerce>(&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 nsIAsyncShutdownClient { 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> nsIAsyncShutdownClientCoerce for T { #[inline] fn coerce_from(v: &nsIAsyncShutdownClient) -> &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 nsIAsyncShutdownClient // 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 nsIAsyncShutdownClientVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* readonly attribute AString name; */ pub GetName: unsafe extern "system" fn (this: *const nsIAsyncShutdownClient, aName: &mut ::nsstring::nsAString) -> nsresult, /* void addBlocker (in nsIAsyncShutdownBlocker aBlocker, in AString aFileName, in long aLineNumber, in AString aStack); */ pub AddBlocker: unsafe extern "system" fn (this: *const nsIAsyncShutdownClient, aBlocker: *const nsIAsyncShutdownBlocker, aFileName: &::nsstring::nsAString, aLineNumber: libc::int32_t, aStack: &::nsstring::nsAString) -> nsresult, /* void removeBlocker (in nsIAsyncShutdownBlocker aBlocker); */ pub RemoveBlocker: unsafe extern "system" fn (this: *const nsIAsyncShutdownClient, aBlocker: *const nsIAsyncShutdownBlocker) -> nsresult, /* readonly attribute jsval jsclient; */ /// Unable to generate binding because `native type JS::Value is unsupported` pub GetJsclient: *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 nsIAsyncShutdownClient { /// ```text /// /** /// * A client for a nsIAsyncShutdownBarrier. /// */ /// /** /// * The name of the barrier. /// */ /// ``` /// /// `readonly attribute AString name;` #[inline] pub unsafe fn GetName(&self, aName: &mut ::nsstring::nsAString) -> nsresult { ((*self.vtable).GetName)(self, aName) } /// ```text /// /** /// * Add a blocker. /// * /// * After a `blocker` has been added with `addBlocker`, if it is not /// * removed with `removeBlocker`, this will, by design, eventually /// * CAUSE A CRASH. /// * /// * Calling `addBlocker` once nsIAsyncShutdownBarrier::wait() has been /// * called on the owning barrier returns an error. /// * /// * @param aBlocker The blocker to add. Once /// * nsIAsyncShutdownBarrier::wait() has been called, it will not /// * call its `aOnReady` callback until all blockers have been /// * removed, each by a call to `removeBlocker`. /// * @param aFileName The filename of the callsite, as given by `__FILE__`. /// * @param aLineNumber The linenumber of the callsite, as given by `__LINE__`. /// * @param aStack Information on the stack that lead to this call. Generally /// * empty when called from C++. /// */ /// ``` /// /// `void addBlocker (in nsIAsyncShutdownBlocker aBlocker, in AString aFileName, in long aLineNumber, in AString aStack);` #[inline] pub unsafe fn AddBlocker(&self, aBlocker: *const nsIAsyncShutdownBlocker, aFileName: &::nsstring::nsAString, aLineNumber: libc::int32_t, aStack: &::nsstring::nsAString) -> nsresult { ((*self.vtable).AddBlocker)(self, aBlocker, aFileName, aLineNumber, aStack) } /// ```text /// /** /// * Remove a blocker. /// * /// * @param aBlocker A blocker previously added to this client through /// * `addBlocker`. Noop if the blocker has never been added or has been /// * removed already. /// */ /// ``` /// /// `void removeBlocker (in nsIAsyncShutdownBlocker aBlocker);` #[inline] pub unsafe fn RemoveBlocker(&self, aBlocker: *const nsIAsyncShutdownBlocker) -> nsresult { ((*self.vtable).RemoveBlocker)(self, aBlocker) } /// ```text /// /** /// * The JS implementation of the client. /// * /// * It is strongly recommended that JS clients of this API use /// * `jsclient` instead of the `nsIAsyncShutdownClient`. See /// * AsyncShutdown.jsm for more information on the JS version of /// * this API. /// */ /// ``` /// /// `readonly attribute jsval jsclient;` const _GetJsclient: () = (); } /// `interface nsIAsyncShutdownCompletionCallback : nsISupports` /// /// ```text /// /** /// * Callback invoked once all blockers of a barrier have been removed. /// */ /// ``` /// // 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 nsIAsyncShutdownCompletionCallback { vtable: *const nsIAsyncShutdownCompletionCallbackVTable, /// 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 nsIAsyncShutdownCompletionCallback. unsafe impl XpCom for nsIAsyncShutdownCompletionCallback { const IID: nsIID = nsID(0x910c9309, 0x1da0, 0x4dd0, [0x8b, 0xdb, 0xa3, 0x25, 0xa3, 0x8c, 0x60, 0x4e]); } // 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 nsIAsyncShutdownCompletionCallback { #[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 nsIAsyncShutdownCompletionCallback. // 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 nsIAsyncShutdownCompletionCallbackCoerce { /// Cheaply cast a value of this type from a `nsIAsyncShutdownCompletionCallback`. fn coerce_from(v: &nsIAsyncShutdownCompletionCallback) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIAsyncShutdownCompletionCallbackCoerce for nsIAsyncShutdownCompletionCallback { #[inline] fn coerce_from(v: &nsIAsyncShutdownCompletionCallback) -> &Self { v } } impl nsIAsyncShutdownCompletionCallback { /// Cast this `nsIAsyncShutdownCompletionCallback` to one of its base interfaces. #[inline] pub fn coerce<T: nsIAsyncShutdownCompletionCallbackCoerce>(&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 nsIAsyncShutdownCompletionCallback { 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> nsIAsyncShutdownCompletionCallbackCoerce for T { #[inline] fn coerce_from(v: &nsIAsyncShutdownCompletionCallback) -> &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 nsIAsyncShutdownCompletionCallback // 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 nsIAsyncShutdownCompletionCallbackVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* void done (); */ pub Done: unsafe extern "system" fn (this: *const nsIAsyncShutdownCompletionCallback) -> 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 nsIAsyncShutdownCompletionCallback { /// ```text /// /** /// * The operation has been completed. /// */ /// ``` /// /// `void done ();` #[inline] pub unsafe fn Done(&self, ) -> nsresult { ((*self.vtable).Done)(self, ) } } /// `interface nsIAsyncShutdownBarrier : nsISupports` /// /// ```text /// /** /// * A stage of shutdown that supports blocker registration. /// */ /// ``` /// // 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 nsIAsyncShutdownBarrier { vtable: *const nsIAsyncShutdownBarrierVTable, /// 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 nsIAsyncShutdownBarrier. unsafe impl XpCom for nsIAsyncShutdownBarrier { const IID: nsIID = nsID(0x50fa8a86, 0x9c91, 0x4256, [0x83, 0x89, 0x17, 0xd3, 0x10, 0xad, 0xec, 0x90]); } // 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 nsIAsyncShutdownBarrier { #[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 nsIAsyncShutdownBarrier. // 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 nsIAsyncShutdownBarrierCoerce { /// Cheaply cast a value of this type from a `nsIAsyncShutdownBarrier`. fn coerce_from(v: &nsIAsyncShutdownBarrier) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIAsyncShutdownBarrierCoerce for nsIAsyncShutdownBarrier { #[inline] fn coerce_from(v: &nsIAsyncShutdownBarrier) -> &Self { v } } impl nsIAsyncShutdownBarrier { /// Cast this `nsIAsyncShutdownBarrier` to one of its base interfaces. #[inline] pub fn coerce<T: nsIAsyncShutdownBarrierCoerce>(&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 nsIAsyncShutdownBarrier { 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> nsIAsyncShutdownBarrierCoerce for T { #[inline] fn coerce_from(v: &nsIAsyncShutdownBarrier) -> &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 nsIAsyncShutdownBarrier // 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 nsIAsyncShutdownBarrierVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* readonly attribute nsIAsyncShutdownClient client; */ pub GetClient: unsafe extern "system" fn (this: *const nsIAsyncShutdownBarrier, aClient: *mut *const nsIAsyncShutdownClient) -> nsresult, /* readonly attribute nsIPropertyBag state; */ pub GetState: unsafe extern "system" fn (this: *const nsIAsyncShutdownBarrier, aState: *mut *const nsIPropertyBag) -> nsresult, /* void wait (in nsIAsyncShutdownCompletionCallback aOnReady); */ pub Wait: unsafe extern "system" fn (this: *const nsIAsyncShutdownBarrier, aOnReady: *const nsIAsyncShutdownCompletionCallback) -> 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 nsIAsyncShutdownBarrier { /// ```text /// /** /// * The blocker registration capability. Most services may wish to /// * publish this capability to let services that depend on it register /// * blockers. /// */ /// ``` /// /// `readonly attribute nsIAsyncShutdownClient client;` #[inline] pub unsafe fn GetClient(&self, aClient: *mut *const nsIAsyncShutdownClient) -> nsresult { ((*self.vtable).GetClient)(self, aClient) } /// ```text /// /** /// * The state of all the blockers of the barrier. /// * /// * See the documentation of `nsIAsyncShutdownBlocker` for the /// * format. /// */ /// ``` /// /// `readonly attribute nsIPropertyBag state;` #[inline] pub unsafe fn GetState(&self, aState: *mut *const nsIPropertyBag) -> nsresult { ((*self.vtable).GetState)(self, aState) } /// ```text /// /** /// * Wait for all blockers to complete. /// * /// * Method `aOnReady` will be called once all blockers have finished. /// * The callback always receives NS_OK. /// */ /// ``` /// /// `void wait (in nsIAsyncShutdownCompletionCallback aOnReady);` #[inline] pub unsafe fn Wait(&self, aOnReady: *const nsIAsyncShutdownCompletionCallback) -> nsresult { ((*self.vtable).Wait)(self, aOnReady) } } /// `interface nsIAsyncShutdownService : nsISupports` /// /// ```text /// /** /// * A service that allows registering shutdown-time dependencies. /// */ /// ``` /// // 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 nsIAsyncShutdownService { vtable: *const nsIAsyncShutdownServiceVTable, /// 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 nsIAsyncShutdownService. unsafe impl XpCom for nsIAsyncShutdownService { const IID: nsIID = nsID(0xdb365c78, 0xc860, 0x4e64, [0x9a, 0x63, 0x25, 0xb7, 0x3f, 0x89, 0xa0, 0x16]); } // 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 nsIAsyncShutdownService { #[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 nsIAsyncShutdownService. // 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 nsIAsyncShutdownServiceCoerce { /// Cheaply cast a value of this type from a `nsIAsyncShutdownService`. fn coerce_from(v: &nsIAsyncShutdownService) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIAsyncShutdownServiceCoerce for nsIAsyncShutdownService { #[inline] fn coerce_from(v: &nsIAsyncShutdownService) -> &Self { v } } impl nsIAsyncShutdownService { /// Cast this `nsIAsyncShutdownService` to one of its base interfaces. #[inline] pub fn coerce<T: nsIAsyncShutdownServiceCoerce>(&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 nsIAsyncShutdownService { 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> nsIAsyncShutdownServiceCoerce for T { #[inline] fn coerce_from(v: &nsIAsyncShutdownService) -> &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 nsIAsyncShutdownService // 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 nsIAsyncShutdownServiceVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* nsIAsyncShutdownBarrier makeBarrier (in AString aName); */ pub MakeBarrier: unsafe extern "system" fn (this: *const nsIAsyncShutdownService, aName: &::nsstring::nsAString, _retval: *mut *const nsIAsyncShutdownBarrier) -> nsresult, /* readonly attribute nsIAsyncShutdownClient profileBeforeChange; */ pub GetProfileBeforeChange: unsafe extern "system" fn (this: *const nsIAsyncShutdownService, aProfileBeforeChange: *mut *const nsIAsyncShutdownClient) -> nsresult, /* readonly attribute nsIAsyncShutdownClient profileChangeTeardown; */ pub GetProfileChangeTeardown: unsafe extern "system" fn (this: *const nsIAsyncShutdownService, aProfileChangeTeardown: *mut *const nsIAsyncShutdownClient) -> nsresult, /* readonly attribute nsIAsyncShutdownClient quitApplicationGranted; */ pub GetQuitApplicationGranted: unsafe extern "system" fn (this: *const nsIAsyncShutdownService, aQuitApplicationGranted: *mut *const nsIAsyncShutdownClient) -> nsresult, /* readonly attribute nsIAsyncShutdownClient sendTelemetry; */ pub GetSendTelemetry: unsafe extern "system" fn (this: *const nsIAsyncShutdownService, aSendTelemetry: *mut *const nsIAsyncShutdownClient) -> nsresult, /* readonly attribute nsIAsyncShutdownClient webWorkersShutdown; */ pub GetWebWorkersShutdown: unsafe extern "system" fn (this: *const nsIAsyncShutdownService, aWebWorkersShutdown: *mut *const nsIAsyncShutdownClient) -> nsresult, /* readonly attribute nsIAsyncShutdownClient xpcomWillShutdown; */ pub GetXpcomWillShutdown: unsafe extern "system" fn (this: *const nsIAsyncShutdownService, aXpcomWillShutdown: *mut *const nsIAsyncShutdownClient) -> 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 nsIAsyncShutdownService { /// ```text /// /** /// * Create a new barrier. /// * /// * By convention, the name should respect the following format: /// * "MyModuleName: Doing something while it's time" /// * e.g. /// * "OS.File: Waiting for clients to flush before shutting down" /// * /// * This attribute is uploaded as part of crash reports. /// */ /// ``` /// /// `nsIAsyncShutdownBarrier makeBarrier (in AString aName);` #[inline] pub unsafe fn MakeBarrier(&self, aName: &::nsstring::nsAString, _retval: *mut *const nsIAsyncShutdownBarrier) -> nsresult { ((*self.vtable).MakeBarrier)(self, aName, _retval) } /// ```text /// /** /// * Barrier for notification profile-before-change. /// */ /// ``` /// /// `readonly attribute nsIAsyncShutdownClient profileBeforeChange;` #[inline] pub unsafe fn GetProfileBeforeChange(&self, aProfileBeforeChange: *mut *const nsIAsyncShutdownClient) -> nsresult { ((*self.vtable).GetProfileBeforeChange)(self, aProfileBeforeChange) } /// ```text /// /** /// * Barrier for notification profile-change-teardown. /// */ /// ``` /// /// `readonly attribute nsIAsyncShutdownClient profileChangeTeardown;` #[inline] pub unsafe fn GetProfileChangeTeardown(&self, aProfileChangeTeardown: *mut *const nsIAsyncShutdownClient) -> nsresult { ((*self.vtable).GetProfileChangeTeardown)(self, aProfileChangeTeardown) } /// ```text /// /** /// * Barrier for notification quit-application-granted. /// */ /// ``` /// /// `readonly attribute nsIAsyncShutdownClient quitApplicationGranted;` #[inline] pub unsafe fn GetQuitApplicationGranted(&self, aQuitApplicationGranted: *mut *const nsIAsyncShutdownClient) -> nsresult { ((*self.vtable).GetQuitApplicationGranted)(self, aQuitApplicationGranted) } /// ```text /// /** /// * Barrier for notification profile-before-change-telemetry. /// */ /// ``` /// /// `readonly attribute nsIAsyncShutdownClient sendTelemetry;` #[inline] pub unsafe fn GetSendTelemetry(&self, aSendTelemetry: *mut *const nsIAsyncShutdownClient) -> nsresult { ((*self.vtable).GetSendTelemetry)(self, aSendTelemetry) } /// ```text /// /** /// * Barrier for notification web-workers-shutdown. /// */ /// ``` /// /// `readonly attribute nsIAsyncShutdownClient webWorkersShutdown;` #[inline] pub unsafe fn GetWebWorkersShutdown(&self, aWebWorkersShutdown: *mut *const nsIAsyncShutdownClient) -> nsresult { ((*self.vtable).GetWebWorkersShutdown)(self, aWebWorkersShutdown) } /// ```text /// /** /// * Barrier for notification xpcom-will-shutdown. /// */ /// ``` /// /// `readonly attribute nsIAsyncShutdownClient xpcomWillShutdown;` #[inline] pub unsafe fn GetXpcomWillShutdown(&self, aXpcomWillShutdown: *mut *const nsIAsyncShutdownClient) -> nsresult { ((*self.vtable).GetXpcomWillShutdown)(self, aXpcomWillShutdown) } }