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 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663
// // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIMIMEInfo.idl // /// `typedef int32_t nsHandlerInfoAction;` /// pub type nsHandlerInfoAction = libc::int32_t; /// `interface nsIHandlerInfo : nsISupports` /// /// ```text /// /** /// * nsIHandlerInfo gives access to the information about how a given protocol /// * scheme or MIME-type is handled. /// */ /// ``` /// // 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 nsIHandlerInfo { vtable: *const nsIHandlerInfoVTable, /// 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 nsIHandlerInfo. unsafe impl XpCom for nsIHandlerInfo { const IID: nsIID = nsID(0x325e56a7, 0x3762, 0x4312, [0xae, 0xc7, 0xf1, 0xfc, 0xf8, 0x4b, 0x41, 0x45]); } // 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 nsIHandlerInfo { #[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 nsIHandlerInfo. // 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 nsIHandlerInfoCoerce { /// Cheaply cast a value of this type from a `nsIHandlerInfo`. fn coerce_from(v: &nsIHandlerInfo) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIHandlerInfoCoerce for nsIHandlerInfo { #[inline] fn coerce_from(v: &nsIHandlerInfo) -> &Self { v } } impl nsIHandlerInfo { /// Cast this `nsIHandlerInfo` to one of its base interfaces. #[inline] pub fn coerce<T: nsIHandlerInfoCoerce>(&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 nsIHandlerInfo { 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> nsIHandlerInfoCoerce for T { #[inline] fn coerce_from(v: &nsIHandlerInfo) -> &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 nsIHandlerInfo // 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 nsIHandlerInfoVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* readonly attribute ACString type; */ pub GetType: unsafe extern "system" fn (this: *const nsIHandlerInfo, aType: &mut ::nsstring::nsACString) -> nsresult, /* attribute AString description; */ pub GetDescription: unsafe extern "system" fn (this: *const nsIHandlerInfo, aDescription: &mut ::nsstring::nsAString) -> nsresult, /* attribute AString description; */ pub SetDescription: unsafe extern "system" fn (this: *const nsIHandlerInfo, aDescription: &::nsstring::nsAString) -> nsresult, /* attribute nsIHandlerApp preferredApplicationHandler; */ pub GetPreferredApplicationHandler: unsafe extern "system" fn (this: *const nsIHandlerInfo, aPreferredApplicationHandler: *mut *const nsIHandlerApp) -> nsresult, /* attribute nsIHandlerApp preferredApplicationHandler; */ pub SetPreferredApplicationHandler: unsafe extern "system" fn (this: *const nsIHandlerInfo, aPreferredApplicationHandler: *const nsIHandlerApp) -> nsresult, /* readonly attribute nsIMutableArray possibleApplicationHandlers; */ pub GetPossibleApplicationHandlers: unsafe extern "system" fn (this: *const nsIHandlerInfo, aPossibleApplicationHandlers: *mut *const nsIMutableArray) -> nsresult, /* readonly attribute boolean hasDefaultHandler; */ pub GetHasDefaultHandler: unsafe extern "system" fn (this: *const nsIHandlerInfo, aHasDefaultHandler: *mut bool) -> nsresult, /* readonly attribute AString defaultDescription; */ pub GetDefaultDescription: unsafe extern "system" fn (this: *const nsIHandlerInfo, aDefaultDescription: &mut ::nsstring::nsAString) -> nsresult, /* void launchWithURI (in nsIURI aURI, [optional] in nsIInterfaceRequestor aWindowContext); */ pub LaunchWithURI: unsafe extern "system" fn (this: *const nsIHandlerInfo, aURI: *const nsIURI, aWindowContext: *const nsIInterfaceRequestor) -> nsresult, /* attribute nsHandlerInfoAction preferredAction; */ pub GetPreferredAction: unsafe extern "system" fn (this: *const nsIHandlerInfo, aPreferredAction: *mut nsHandlerInfoAction) -> nsresult, /* attribute nsHandlerInfoAction preferredAction; */ pub SetPreferredAction: unsafe extern "system" fn (this: *const nsIHandlerInfo, aPreferredAction: nsHandlerInfoAction) -> nsresult, /* attribute boolean alwaysAskBeforeHandling; */ pub GetAlwaysAskBeforeHandling: unsafe extern "system" fn (this: *const nsIHandlerInfo, aAlwaysAskBeforeHandling: *mut bool) -> nsresult, /* attribute boolean alwaysAskBeforeHandling; */ pub SetAlwaysAskBeforeHandling: unsafe extern "system" fn (this: *const nsIHandlerInfo, aAlwaysAskBeforeHandling: bool) -> 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 nsIHandlerInfo { pub const saveToDisk: i64 = 0; /// ```text /// /** /// * Used to indicate that we know nothing about what to do with this. You /// * could consider this to be not initialized. /// */ /// ``` /// pub const alwaysAsk: i64 = 1; pub const useHelperApp: i64 = 2; pub const handleInternally: i64 = 3; pub const useSystemDefault: i64 = 4; /// ```text /// /** /// * The type of this handler info. For MIME handlers, this is the MIME type. /// * For protocol handlers, it's the scheme. /// * /// * @return String representing the type. /// */ /// ``` /// /// `readonly attribute ACString type;` #[inline] pub unsafe fn GetType(&self, aType: &mut ::nsstring::nsACString) -> nsresult { ((*self.vtable).GetType)(self, aType) } /// ```text /// /** /// * A human readable description of the handler type /// */ /// ``` /// /// `attribute AString description;` #[inline] pub unsafe fn GetDescription(&self, aDescription: &mut ::nsstring::nsAString) -> nsresult { ((*self.vtable).GetDescription)(self, aDescription) } /// ```text /// /** /// * A human readable description of the handler type /// */ /// ``` /// /// `attribute AString description;` #[inline] pub unsafe fn SetDescription(&self, aDescription: &::nsstring::nsAString) -> nsresult { ((*self.vtable).SetDescription)(self, aDescription) } /// ```text /// /** /// * The application the user has said they want associated with this content /// * type. This is not always guaranteed to be set!! /// */ /// ``` /// /// `attribute nsIHandlerApp preferredApplicationHandler;` #[inline] pub unsafe fn GetPreferredApplicationHandler(&self, aPreferredApplicationHandler: *mut *const nsIHandlerApp) -> nsresult { ((*self.vtable).GetPreferredApplicationHandler)(self, aPreferredApplicationHandler) } /// ```text /// /** /// * The application the user has said they want associated with this content /// * type. This is not always guaranteed to be set!! /// */ /// ``` /// /// `attribute nsIHandlerApp preferredApplicationHandler;` #[inline] pub unsafe fn SetPreferredApplicationHandler(&self, aPreferredApplicationHandler: *const nsIHandlerApp) -> nsresult { ((*self.vtable).SetPreferredApplicationHandler)(self, aPreferredApplicationHandler) } /// ```text /// /** /// * Applications that can handle this content type. /// * /// * The list will include the preferred handler, if any. Elements of this /// * array are nsIHandlerApp objects, and this attribute will always reference /// * an array, whether or not there are any possible handlers. If there are /// * no possible handlers, the array will contain no elements, so just check /// * its length (nsIArray::length) to see if there are any possible handlers. /// */ /// ``` /// /// `readonly attribute nsIMutableArray possibleApplicationHandlers;` #[inline] pub unsafe fn GetPossibleApplicationHandlers(&self, aPossibleApplicationHandlers: *mut *const nsIMutableArray) -> nsresult { ((*self.vtable).GetPossibleApplicationHandlers)(self, aPossibleApplicationHandlers) } /// ```text /// /** /// * Indicates whether a default application handler exists, /// * i.e. whether launchWithFile with action = useSystemDefault is possible /// * and defaultDescription will contain usable information. /// */ /// ``` /// /// `readonly attribute boolean hasDefaultHandler;` #[inline] pub unsafe fn GetHasDefaultHandler(&self, aHasDefaultHandler: *mut bool) -> nsresult { ((*self.vtable).GetHasDefaultHandler)(self, aHasDefaultHandler) } /// ```text /// /** /// * A pretty name description of the associated default application. Only /// * usable if hasDefaultHandler is true. /// */ /// ``` /// /// `readonly attribute AString defaultDescription;` #[inline] pub unsafe fn GetDefaultDescription(&self, aDefaultDescription: &mut ::nsstring::nsAString) -> nsresult { ((*self.vtable).GetDefaultDescription)(self, aDefaultDescription) } /// ```text /// /** /// * Launches the application with the specified URI, in a way that /// * depends on the value of preferredAction. preferredAction must be /// * useHelperApp or useSystemDefault. /// * /// * @note Only the URI scheme is used to determine how to launch. This is /// * essentially a pass-by-value operation. This means that in the case of /// * a file: URI, the handler that is registered for file: will be launched /// * and our code will not make any decision based on the content-type or /// * extension, though the invoked file: handler is free to do so. /// * /// * @param aURI /// * The URI to launch this application with /// * /// * @param aWindowContext /// * The window to parent the dialog against, and, if a web handler /// * is chosen, it is loaded in this window as well. See /// * nsIHandlerApp.launchWithURI for more details. /// * /// * @throw NS_ERROR_INVALID_ARG if preferredAction is not valid for this /// * call. Other exceptions may be thrown. /// */ /// ``` /// /// `void launchWithURI (in nsIURI aURI, [optional] in nsIInterfaceRequestor aWindowContext);` #[inline] pub unsafe fn LaunchWithURI(&self, aURI: *const nsIURI, aWindowContext: *const nsIInterfaceRequestor) -> nsresult { ((*self.vtable).LaunchWithURI)(self, aURI, aWindowContext) } /// ```text /// /** /// * preferredAction is how the user specified they would like to handle /// * this content type: save to disk, use specified helper app, use OS /// * default handler or handle using navigator; possible value constants /// * listed below /// */ /// ``` /// /// `attribute nsHandlerInfoAction preferredAction;` #[inline] pub unsafe fn GetPreferredAction(&self, aPreferredAction: *mut nsHandlerInfoAction) -> nsresult { ((*self.vtable).GetPreferredAction)(self, aPreferredAction) } /// ```text /// /** /// * preferredAction is how the user specified they would like to handle /// * this content type: save to disk, use specified helper app, use OS /// * default handler or handle using navigator; possible value constants /// * listed below /// */ /// ``` /// /// `attribute nsHandlerInfoAction preferredAction;` #[inline] pub unsafe fn SetPreferredAction(&self, aPreferredAction: nsHandlerInfoAction) -> nsresult { ((*self.vtable).SetPreferredAction)(self, aPreferredAction) } /// ```text /// /** /// * alwaysAskBeforeHandling: if true, we should always give the user a /// * dialog asking how to dispose of this content. /// */ /// ``` /// /// `attribute boolean alwaysAskBeforeHandling;` #[inline] pub unsafe fn GetAlwaysAskBeforeHandling(&self, aAlwaysAskBeforeHandling: *mut bool) -> nsresult { ((*self.vtable).GetAlwaysAskBeforeHandling)(self, aAlwaysAskBeforeHandling) } /// ```text /// /** /// * alwaysAskBeforeHandling: if true, we should always give the user a /// * dialog asking how to dispose of this content. /// */ /// ``` /// /// `attribute boolean alwaysAskBeforeHandling;` #[inline] pub unsafe fn SetAlwaysAskBeforeHandling(&self, aAlwaysAskBeforeHandling: bool) -> nsresult { ((*self.vtable).SetAlwaysAskBeforeHandling)(self, aAlwaysAskBeforeHandling) } } /// `interface nsIMIMEInfo : nsIHandlerInfo` /// /// ```text /// /** /// * nsIMIMEInfo extends nsIHandlerInfo with a bunch of information specific to /// * MIME content-types. There is a one-to-many relationship between MIME types /// * and file extensions. This means that a MIMEInfo object may have multiple /// * file extensions associated with it. However, the reverse is not true. /// * /// * MIMEInfo objects are generally retrieved from the MIME Service /// * @see nsIMIMEService /// */ /// ``` /// // 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 nsIMIMEInfo { vtable: *const nsIMIMEInfoVTable, /// 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 nsIMIMEInfo. unsafe impl XpCom for nsIMIMEInfo { const IID: nsIID = nsID(0x1c21acef, 0xc7a1, 0x40c6, [0x9d, 0x40, 0xa2, 0x04, 0x80, 0xee, 0x53, 0xa1]); } // 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 nsIMIMEInfo { #[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 nsIMIMEInfo. // 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 nsIMIMEInfoCoerce { /// Cheaply cast a value of this type from a `nsIMIMEInfo`. fn coerce_from(v: &nsIMIMEInfo) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIMIMEInfoCoerce for nsIMIMEInfo { #[inline] fn coerce_from(v: &nsIMIMEInfo) -> &Self { v } } impl nsIMIMEInfo { /// Cast this `nsIMIMEInfo` to one of its base interfaces. #[inline] pub fn coerce<T: nsIMIMEInfoCoerce>(&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 nsIMIMEInfo { type Target = nsIHandlerInfo; #[inline] fn deref(&self) -> &nsIHandlerInfo { 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: nsIHandlerInfoCoerce> nsIMIMEInfoCoerce for T { #[inline] fn coerce_from(v: &nsIMIMEInfo) -> &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 nsIMIMEInfo // 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 nsIMIMEInfoVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsIHandlerInfoVTable, /* nsIUTF8StringEnumerator getFileExtensions (); */ pub GetFileExtensions: unsafe extern "system" fn (this: *const nsIMIMEInfo, _retval: *mut *const nsIUTF8StringEnumerator) -> nsresult, /* void setFileExtensions (in AUTF8String aExtensions); */ pub SetFileExtensions: unsafe extern "system" fn (this: *const nsIMIMEInfo, aExtensions: &::nsstring::nsACString) -> nsresult, /* boolean extensionExists (in AUTF8String aExtension); */ pub ExtensionExists: unsafe extern "system" fn (this: *const nsIMIMEInfo, aExtension: &::nsstring::nsACString, _retval: *mut bool) -> nsresult, /* void appendExtension (in AUTF8String aExtension); */ pub AppendExtension: unsafe extern "system" fn (this: *const nsIMIMEInfo, aExtension: &::nsstring::nsACString) -> nsresult, /* attribute AUTF8String primaryExtension; */ pub GetPrimaryExtension: unsafe extern "system" fn (this: *const nsIMIMEInfo, aPrimaryExtension: &mut ::nsstring::nsACString) -> nsresult, /* attribute AUTF8String primaryExtension; */ pub SetPrimaryExtension: unsafe extern "system" fn (this: *const nsIMIMEInfo, aPrimaryExtension: &::nsstring::nsACString) -> nsresult, /* readonly attribute ACString MIMEType; */ pub GetMIMEType: unsafe extern "system" fn (this: *const nsIMIMEInfo, aMIMEType: &mut ::nsstring::nsACString) -> nsresult, /* boolean equals (in nsIMIMEInfo aMIMEInfo); */ pub Equals: unsafe extern "system" fn (this: *const nsIMIMEInfo, aMIMEInfo: *const nsIMIMEInfo, _retval: *mut bool) -> nsresult, /* readonly attribute nsIArray possibleLocalHandlers; */ pub GetPossibleLocalHandlers: unsafe extern "system" fn (this: *const nsIMIMEInfo, aPossibleLocalHandlers: *mut *const nsIArray) -> nsresult, /* void launchWithFile (in nsIFile aFile); */ pub LaunchWithFile: unsafe extern "system" fn (this: *const nsIMIMEInfo, aFile: *const nsIFile) -> 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 nsIMIMEInfo { /// ```text /// /** /// * Gives you an array of file types associated with this type. /// * /// * @return Number of elements in the array. /// * @return Array of extensions. /// */ /// ``` /// /// `nsIUTF8StringEnumerator getFileExtensions ();` #[inline] pub unsafe fn GetFileExtensions(&self, _retval: *mut *const nsIUTF8StringEnumerator) -> nsresult { ((*self.vtable).GetFileExtensions)(self, _retval) } /// ```text /// /** /// * Set File Extensions. Input is a comma delimited list of extensions. /// */ /// ``` /// /// `void setFileExtensions (in AUTF8String aExtensions);` #[inline] pub unsafe fn SetFileExtensions(&self, aExtensions: &::nsstring::nsACString) -> nsresult { ((*self.vtable).SetFileExtensions)(self, aExtensions) } /// ```text /// /** /// * Returns whether or not the given extension is /// * associated with this MIME info. /// * /// * @return TRUE if the association exists. /// */ /// ``` /// /// `boolean extensionExists (in AUTF8String aExtension);` #[inline] pub unsafe fn ExtensionExists(&self, aExtension: &::nsstring::nsACString, _retval: *mut bool) -> nsresult { ((*self.vtable).ExtensionExists)(self, aExtension, _retval) } /// ```text /// /** /// * Append a given extension to the set of extensions /// */ /// ``` /// /// `void appendExtension (in AUTF8String aExtension);` #[inline] pub unsafe fn AppendExtension(&self, aExtension: &::nsstring::nsACString) -> nsresult { ((*self.vtable).AppendExtension)(self, aExtension) } /// ```text /// /** /// * Returns the first extension association in /// * the internal set of extensions. /// * /// * @return The first extension. /// */ /// ``` /// /// `attribute AUTF8String primaryExtension;` #[inline] pub unsafe fn GetPrimaryExtension(&self, aPrimaryExtension: &mut ::nsstring::nsACString) -> nsresult { ((*self.vtable).GetPrimaryExtension)(self, aPrimaryExtension) } /// ```text /// /** /// * Returns the first extension association in /// * the internal set of extensions. /// * /// * @return The first extension. /// */ /// ``` /// /// `attribute AUTF8String primaryExtension;` #[inline] pub unsafe fn SetPrimaryExtension(&self, aPrimaryExtension: &::nsstring::nsACString) -> nsresult { ((*self.vtable).SetPrimaryExtension)(self, aPrimaryExtension) } /// ```text /// /** /// * The MIME type of this MIMEInfo. /// * /// * @return String representing the MIME type. /// * /// * @deprecated use nsIHandlerInfo::type instead. /// */ /// ``` /// /// `readonly attribute ACString MIMEType;` #[inline] pub unsafe fn GetMIMEType(&self, aMIMEType: &mut ::nsstring::nsACString) -> nsresult { ((*self.vtable).GetMIMEType)(self, aMIMEType) } /// ```text /// /** /// * Returns whether or not these two nsIMIMEInfos are logically /// * equivalent. /// * /// * @returns PR_TRUE if the two are considered equal /// */ /// ``` /// /// `boolean equals (in nsIMIMEInfo aMIMEInfo);` #[inline] pub unsafe fn Equals(&self, aMIMEInfo: *const nsIMIMEInfo, _retval: *mut bool) -> nsresult { ((*self.vtable).Equals)(self, aMIMEInfo, _retval) } /// ```text /// /** /// * Returns a list of nsILocalHandlerApp objects containing /// * handlers associated with this mimeinfo. Implemented per /// * platform using information in this object to generate the /// * best list. Typically used for an "open with" style user /// * option. /// * /// * @return nsIArray of nsILocalHandlerApp /// */ /// ``` /// /// `readonly attribute nsIArray possibleLocalHandlers;` #[inline] pub unsafe fn GetPossibleLocalHandlers(&self, aPossibleLocalHandlers: *mut *const nsIArray) -> nsresult { ((*self.vtable).GetPossibleLocalHandlers)(self, aPossibleLocalHandlers) } /// ```text /// /** /// * Launches the application with the specified file, in a way that /// * depends on the value of preferredAction. preferredAction must be /// * useHelperApp or useSystemDefault. /// * /// * @param aFile The file to launch this application with. /// * /// * @throw NS_ERROR_INVALID_ARG if action is not valid for this function. /// * Other exceptions may be thrown. /// */ /// ``` /// /// `void launchWithFile (in nsIFile aFile);` #[inline] pub unsafe fn LaunchWithFile(&self, aFile: *const nsIFile) -> nsresult { ((*self.vtable).LaunchWithFile)(self, aFile) } } /// `interface nsIHandlerApp : 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 nsIHandlerApp { vtable: *const nsIHandlerAppVTable, /// 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 nsIHandlerApp. unsafe impl XpCom for nsIHandlerApp { const IID: nsIID = nsID(0x8bdf20a4, 0x9170, 0x4548, [0xaf, 0x52, 0x78, 0x31, 0x1a, 0x44, 0xf9, 0x20]); } // 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 nsIHandlerApp { #[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 nsIHandlerApp. // 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 nsIHandlerAppCoerce { /// Cheaply cast a value of this type from a `nsIHandlerApp`. fn coerce_from(v: &nsIHandlerApp) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIHandlerAppCoerce for nsIHandlerApp { #[inline] fn coerce_from(v: &nsIHandlerApp) -> &Self { v } } impl nsIHandlerApp { /// Cast this `nsIHandlerApp` to one of its base interfaces. #[inline] pub fn coerce<T: nsIHandlerAppCoerce>(&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 nsIHandlerApp { 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> nsIHandlerAppCoerce for T { #[inline] fn coerce_from(v: &nsIHandlerApp) -> &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 nsIHandlerApp // 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 nsIHandlerAppVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* attribute AString name; */ pub GetName: unsafe extern "system" fn (this: *const nsIHandlerApp, aName: &mut ::nsstring::nsAString) -> nsresult, /* attribute AString name; */ pub SetName: unsafe extern "system" fn (this: *const nsIHandlerApp, aName: &::nsstring::nsAString) -> nsresult, /* attribute AString detailedDescription; */ pub GetDetailedDescription: unsafe extern "system" fn (this: *const nsIHandlerApp, aDetailedDescription: &mut ::nsstring::nsAString) -> nsresult, /* attribute AString detailedDescription; */ pub SetDetailedDescription: unsafe extern "system" fn (this: *const nsIHandlerApp, aDetailedDescription: &::nsstring::nsAString) -> nsresult, /* boolean equals (in nsIHandlerApp aHandlerApp); */ pub Equals: unsafe extern "system" fn (this: *const nsIHandlerApp, aHandlerApp: *const nsIHandlerApp, _retval: *mut bool) -> nsresult, /* void launchWithURI (in nsIURI aURI, [optional] in nsIInterfaceRequestor aWindowContext); */ pub LaunchWithURI: unsafe extern "system" fn (this: *const nsIHandlerApp, aURI: *const nsIURI, aWindowContext: *const nsIInterfaceRequestor) -> 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 nsIHandlerApp { /// ```text /// /** /// * nsIHandlerApp represents an external application that can handle content /// * of some sort (either a MIME type or a protocol). /// * /// * FIXME: now that we've made nsIWebHandlerApp inherit from nsIHandlerApp, /// * we should also try to make nsIWebContentHandlerInfo inherit from or possibly /// * be replaced by nsIWebHandlerApp (bug 394710). /// */ /// /** /// * Human readable name for the handler /// */ /// ``` /// /// `attribute AString name;` #[inline] pub unsafe fn GetName(&self, aName: &mut ::nsstring::nsAString) -> nsresult { ((*self.vtable).GetName)(self, aName) } /// ```text /// /** /// * nsIHandlerApp represents an external application that can handle content /// * of some sort (either a MIME type or a protocol). /// * /// * FIXME: now that we've made nsIWebHandlerApp inherit from nsIHandlerApp, /// * we should also try to make nsIWebContentHandlerInfo inherit from or possibly /// * be replaced by nsIWebHandlerApp (bug 394710). /// */ /// /** /// * Human readable name for the handler /// */ /// ``` /// /// `attribute AString name;` #[inline] pub unsafe fn SetName(&self, aName: &::nsstring::nsAString) -> nsresult { ((*self.vtable).SetName)(self, aName) } /// ```text /// /** /// * Detailed description for this handler. Suitable for /// * a tooltip or short informative sentence. /// */ /// ``` /// /// `attribute AString detailedDescription;` #[inline] pub unsafe fn GetDetailedDescription(&self, aDetailedDescription: &mut ::nsstring::nsAString) -> nsresult { ((*self.vtable).GetDetailedDescription)(self, aDetailedDescription) } /// ```text /// /** /// * Detailed description for this handler. Suitable for /// * a tooltip or short informative sentence. /// */ /// ``` /// /// `attribute AString detailedDescription;` #[inline] pub unsafe fn SetDetailedDescription(&self, aDetailedDescription: &::nsstring::nsAString) -> nsresult { ((*self.vtable).SetDetailedDescription)(self, aDetailedDescription) } /// ```text /// /** /// * Whether or not the given handler app is logically equivalent to the /// * invokant (i.e. they represent the same app). /// * /// * Two apps are the same if they are both either local or web handlers /// * and their executables/URI templates and command line parameters are /// * the same. /// * /// * @param aHandlerApp the handler app to compare to the invokant /// * /// * @returns true if the two are logically equivalent, false otherwise /// */ /// ``` /// /// `boolean equals (in nsIHandlerApp aHandlerApp);` #[inline] pub unsafe fn Equals(&self, aHandlerApp: *const nsIHandlerApp, _retval: *mut bool) -> nsresult { ((*self.vtable).Equals)(self, aHandlerApp, _retval) } /// ```text /// /** /// * Launches the application with the specified URI. /// * /// * @param aURI /// * The URI to launch this application with /// * /// * @param aWindowContext /// * /// * Currently only relevant to web-handler apps. If given, this /// * represents the docshell to load the handler in and is passed /// * through to nsIURILoader.openURI. If this parameter is null or /// * not present, the web handler app implementation will attempt to /// * find/create a place to load the handler and do so. As of this /// * writing, it tries to load the web handler in a new window using /// * nsIBrowserDOMWindow.openURI. In the future, it may attempt to /// * have a more comprehensive strategy which could include handing /// * off to the system default browser (bug 394479). /// */ /// ``` /// /// `void launchWithURI (in nsIURI aURI, [optional] in nsIInterfaceRequestor aWindowContext);` #[inline] pub unsafe fn LaunchWithURI(&self, aURI: *const nsIURI, aWindowContext: *const nsIInterfaceRequestor) -> nsresult { ((*self.vtable).LaunchWithURI)(self, aURI, aWindowContext) } } /// `interface nsILocalHandlerApp : nsIHandlerApp` /// /// ```text /// /** /// * nsILocalHandlerApp is a local OS-level executable /// */ /// ``` /// // 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 nsILocalHandlerApp { vtable: *const nsILocalHandlerAppVTable, /// 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 nsILocalHandlerApp. unsafe impl XpCom for nsILocalHandlerApp { const IID: nsIID = nsID(0xd36b6329, 0x52ae, 0x4f45, [0x80, 0xf4, 0xb2, 0x53, 0x6a, 0xe5, 0xf8, 0xb2]); } // 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 nsILocalHandlerApp { #[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 nsILocalHandlerApp. // 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 nsILocalHandlerAppCoerce { /// Cheaply cast a value of this type from a `nsILocalHandlerApp`. fn coerce_from(v: &nsILocalHandlerApp) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsILocalHandlerAppCoerce for nsILocalHandlerApp { #[inline] fn coerce_from(v: &nsILocalHandlerApp) -> &Self { v } } impl nsILocalHandlerApp { /// Cast this `nsILocalHandlerApp` to one of its base interfaces. #[inline] pub fn coerce<T: nsILocalHandlerAppCoerce>(&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 nsILocalHandlerApp { type Target = nsIHandlerApp; #[inline] fn deref(&self) -> &nsIHandlerApp { 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: nsIHandlerAppCoerce> nsILocalHandlerAppCoerce for T { #[inline] fn coerce_from(v: &nsILocalHandlerApp) -> &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 nsILocalHandlerApp // 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 nsILocalHandlerAppVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsIHandlerAppVTable, /* attribute nsIFile executable; */ pub GetExecutable: unsafe extern "system" fn (this: *const nsILocalHandlerApp, aExecutable: *mut *const nsIFile) -> nsresult, /* attribute nsIFile executable; */ pub SetExecutable: unsafe extern "system" fn (this: *const nsILocalHandlerApp, aExecutable: *const nsIFile) -> nsresult, /* readonly attribute unsigned long parameterCount; */ pub GetParameterCount: unsafe extern "system" fn (this: *const nsILocalHandlerApp, aParameterCount: *mut libc::uint32_t) -> nsresult, /* void clearParameters (); */ pub ClearParameters: unsafe extern "system" fn (this: *const nsILocalHandlerApp) -> nsresult, /* void appendParameter (in AString param); */ pub AppendParameter: unsafe extern "system" fn (this: *const nsILocalHandlerApp, param: &::nsstring::nsAString) -> nsresult, /* AString getParameter (in unsigned long parameterIndex); */ pub GetParameter: unsafe extern "system" fn (this: *const nsILocalHandlerApp, parameterIndex: libc::uint32_t, _retval: &mut ::nsstring::nsAString) -> nsresult, /* boolean parameterExists (in AString param); */ pub ParameterExists: unsafe extern "system" fn (this: *const nsILocalHandlerApp, param: &::nsstring::nsAString, _retval: *mut bool) -> 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 nsILocalHandlerApp { /// ```text /// /** /// * Pointer to the executable file used to handle content /// */ /// ``` /// /// `attribute nsIFile executable;` #[inline] pub unsafe fn GetExecutable(&self, aExecutable: *mut *const nsIFile) -> nsresult { ((*self.vtable).GetExecutable)(self, aExecutable) } /// ```text /// /** /// * Pointer to the executable file used to handle content /// */ /// ``` /// /// `attribute nsIFile executable;` #[inline] pub unsafe fn SetExecutable(&self, aExecutable: *const nsIFile) -> nsresult { ((*self.vtable).SetExecutable)(self, aExecutable) } /// ```text /// /** /// * Returns the current number of command line parameters. /// */ /// ``` /// /// `readonly attribute unsigned long parameterCount;` #[inline] pub unsafe fn GetParameterCount(&self, aParameterCount: *mut libc::uint32_t) -> nsresult { ((*self.vtable).GetParameterCount)(self, aParameterCount) } /// ```text /// /** /// * Clears the current list of command line parameters. /// */ /// ``` /// /// `void clearParameters ();` #[inline] pub unsafe fn ClearParameters(&self, ) -> nsresult { ((*self.vtable).ClearParameters)(self, ) } /// ```text /// /** /// * Appends a command line parameter to the command line /// * parameter list. /// * /// * @param param the parameter to add. /// */ /// ``` /// /// `void appendParameter (in AString param);` #[inline] pub unsafe fn AppendParameter(&self, param: &::nsstring::nsAString) -> nsresult { ((*self.vtable).AppendParameter)(self, param) } /// ```text /// /** /// * Retrieves a specific command line parameter. /// * /// * @param param the index of the parameter to return. /// * /// * @return the parameter string. /// * /// * @throw NS_ERROR_INVALID_ARG if the index is out of range. /// */ /// ``` /// /// `AString getParameter (in unsigned long parameterIndex);` #[inline] pub unsafe fn GetParameter(&self, parameterIndex: libc::uint32_t, _retval: &mut ::nsstring::nsAString) -> nsresult { ((*self.vtable).GetParameter)(self, parameterIndex, _retval) } /// ```text /// /** /// * Checks to see if a parameter exists in the command line /// * parameter list. /// * /// * @param param the parameter to search for. /// * /// * @return TRUE if the parameter exists in the current list. /// */ /// ``` /// /// `boolean parameterExists (in AString param);` #[inline] pub unsafe fn ParameterExists(&self, param: &::nsstring::nsAString, _retval: *mut bool) -> nsresult { ((*self.vtable).ParameterExists)(self, param, _retval) } } /// `interface nsIWebHandlerApp : nsIHandlerApp` /// /// ```text /// /** /// * nsIWebHandlerApp is a web-based handler, as speced by the WhatWG HTML5 /// * draft. Currently, only GET-based handlers are supported. At some point, /// * we probably want to work with WhatWG to spec out and implement POST-based /// * handlers as well. /// */ /// ``` /// // 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 nsIWebHandlerApp { vtable: *const nsIWebHandlerAppVTable, /// 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 nsIWebHandlerApp. unsafe impl XpCom for nsIWebHandlerApp { const IID: nsIID = nsID(0x7521a093, 0xc498, 0x45ce, [0xb4, 0x62, 0xdf, 0x7b, 0xa0, 0xd8, 0x82, 0xf6]); } // 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 nsIWebHandlerApp { #[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 nsIWebHandlerApp. // 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 nsIWebHandlerAppCoerce { /// Cheaply cast a value of this type from a `nsIWebHandlerApp`. fn coerce_from(v: &nsIWebHandlerApp) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIWebHandlerAppCoerce for nsIWebHandlerApp { #[inline] fn coerce_from(v: &nsIWebHandlerApp) -> &Self { v } } impl nsIWebHandlerApp { /// Cast this `nsIWebHandlerApp` to one of its base interfaces. #[inline] pub fn coerce<T: nsIWebHandlerAppCoerce>(&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 nsIWebHandlerApp { type Target = nsIHandlerApp; #[inline] fn deref(&self) -> &nsIHandlerApp { 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: nsIHandlerAppCoerce> nsIWebHandlerAppCoerce for T { #[inline] fn coerce_from(v: &nsIWebHandlerApp) -> &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 nsIWebHandlerApp // 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 nsIWebHandlerAppVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsIHandlerAppVTable, /* attribute AUTF8String uriTemplate; */ pub GetUriTemplate: unsafe extern "system" fn (this: *const nsIWebHandlerApp, aUriTemplate: &mut ::nsstring::nsACString) -> nsresult, /* attribute AUTF8String uriTemplate; */ pub SetUriTemplate: unsafe extern "system" fn (this: *const nsIWebHandlerApp, aUriTemplate: &::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 nsIWebHandlerApp { /// ```text /// /** /// * Template used to construct the URI to GET. Template is expected to have /// * a %s in it, and the escaped URI to be handled is inserted in place of /// * that %s, as per the HTML5 spec. /// */ /// ``` /// /// `attribute AUTF8String uriTemplate;` #[inline] pub unsafe fn GetUriTemplate(&self, aUriTemplate: &mut ::nsstring::nsACString) -> nsresult { ((*self.vtable).GetUriTemplate)(self, aUriTemplate) } /// ```text /// /** /// * Template used to construct the URI to GET. Template is expected to have /// * a %s in it, and the escaped URI to be handled is inserted in place of /// * that %s, as per the HTML5 spec. /// */ /// ``` /// /// `attribute AUTF8String uriTemplate;` #[inline] pub unsafe fn SetUriTemplate(&self, aUriTemplate: &::nsstring::nsACString) -> nsresult { ((*self.vtable).SetUriTemplate)(self, aUriTemplate) } } /// `interface nsIDBusHandlerApp : nsIHandlerApp` /// /// ```text /// /** /// * nsIDBusHandlerApp represents local applications launched by DBus a message /// * invoking a method taking a single string argument descibing a URI /// */ /// ``` /// // 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 nsIDBusHandlerApp { vtable: *const nsIDBusHandlerAppVTable, /// 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 nsIDBusHandlerApp. unsafe impl XpCom for nsIDBusHandlerApp { const IID: nsIID = nsID(0x1ffc274b, 0x4cbf, 0x4bb5, [0xa6, 0x35, 0x05, 0xad, 0x2c, 0xbb, 0x65, 0x34]); } // 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 nsIDBusHandlerApp { #[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 nsIDBusHandlerApp. // 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 nsIDBusHandlerAppCoerce { /// Cheaply cast a value of this type from a `nsIDBusHandlerApp`. fn coerce_from(v: &nsIDBusHandlerApp) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIDBusHandlerAppCoerce for nsIDBusHandlerApp { #[inline] fn coerce_from(v: &nsIDBusHandlerApp) -> &Self { v } } impl nsIDBusHandlerApp { /// Cast this `nsIDBusHandlerApp` to one of its base interfaces. #[inline] pub fn coerce<T: nsIDBusHandlerAppCoerce>(&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 nsIDBusHandlerApp { type Target = nsIHandlerApp; #[inline] fn deref(&self) -> &nsIHandlerApp { 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: nsIHandlerAppCoerce> nsIDBusHandlerAppCoerce for T { #[inline] fn coerce_from(v: &nsIDBusHandlerApp) -> &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 nsIDBusHandlerApp // 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 nsIDBusHandlerAppVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsIHandlerAppVTable, /* attribute AUTF8String service; */ pub GetService: unsafe extern "system" fn (this: *const nsIDBusHandlerApp, aService: &mut ::nsstring::nsACString) -> nsresult, /* attribute AUTF8String service; */ pub SetService: unsafe extern "system" fn (this: *const nsIDBusHandlerApp, aService: &::nsstring::nsACString) -> nsresult, /* attribute AUTF8String objectPath; */ pub GetObjectPath: unsafe extern "system" fn (this: *const nsIDBusHandlerApp, aObjectPath: &mut ::nsstring::nsACString) -> nsresult, /* attribute AUTF8String objectPath; */ pub SetObjectPath: unsafe extern "system" fn (this: *const nsIDBusHandlerApp, aObjectPath: &::nsstring::nsACString) -> nsresult, /* attribute AUTF8String dBusInterface; */ pub GetDBusInterface: unsafe extern "system" fn (this: *const nsIDBusHandlerApp, aDBusInterface: &mut ::nsstring::nsACString) -> nsresult, /* attribute AUTF8String dBusInterface; */ pub SetDBusInterface: unsafe extern "system" fn (this: *const nsIDBusHandlerApp, aDBusInterface: &::nsstring::nsACString) -> nsresult, /* attribute AUTF8String method; */ pub GetMethod: unsafe extern "system" fn (this: *const nsIDBusHandlerApp, aMethod: &mut ::nsstring::nsACString) -> nsresult, /* attribute AUTF8String method; */ pub SetMethod: unsafe extern "system" fn (this: *const nsIDBusHandlerApp, aMethod: &::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 nsIDBusHandlerApp { /// ```text /// /** /// * Service defines the dbus service that should handle this protocol. /// * If its not set, NS_ERROR_FAILURE will be returned by LaunchWithURI /// */ /// ``` /// /// `attribute AUTF8String service;` #[inline] pub unsafe fn GetService(&self, aService: &mut ::nsstring::nsACString) -> nsresult { ((*self.vtable).GetService)(self, aService) } /// ```text /// /** /// * Service defines the dbus service that should handle this protocol. /// * If its not set, NS_ERROR_FAILURE will be returned by LaunchWithURI /// */ /// ``` /// /// `attribute AUTF8String service;` #[inline] pub unsafe fn SetService(&self, aService: &::nsstring::nsACString) -> nsresult { ((*self.vtable).SetService)(self, aService) } /// ```text /// /** /// * Objpath defines the object path of the dbus service that should handle /// * this protocol. If its not set, NS_ERROR_FAILURE will be returned /// * by LaunchWithURI /// */ /// ``` /// /// `attribute AUTF8String objectPath;` #[inline] pub unsafe fn GetObjectPath(&self, aObjectPath: &mut ::nsstring::nsACString) -> nsresult { ((*self.vtable).GetObjectPath)(self, aObjectPath) } /// ```text /// /** /// * Objpath defines the object path of the dbus service that should handle /// * this protocol. If its not set, NS_ERROR_FAILURE will be returned /// * by LaunchWithURI /// */ /// ``` /// /// `attribute AUTF8String objectPath;` #[inline] pub unsafe fn SetObjectPath(&self, aObjectPath: &::nsstring::nsACString) -> nsresult { ((*self.vtable).SetObjectPath)(self, aObjectPath) } /// ```text /// /** /// * DBusInterface defines the interface of the dbus service that should /// * handle this protocol. If its not set, NS_ERROR_FAILURE will be /// * returned by LaunchWithURI /// */ /// ``` /// /// `attribute AUTF8String dBusInterface;` #[inline] pub unsafe fn GetDBusInterface(&self, aDBusInterface: &mut ::nsstring::nsACString) -> nsresult { ((*self.vtable).GetDBusInterface)(self, aDBusInterface) } /// ```text /// /** /// * DBusInterface defines the interface of the dbus service that should /// * handle this protocol. If its not set, NS_ERROR_FAILURE will be /// * returned by LaunchWithURI /// */ /// ``` /// /// `attribute AUTF8String dBusInterface;` #[inline] pub unsafe fn SetDBusInterface(&self, aDBusInterface: &::nsstring::nsACString) -> nsresult { ((*self.vtable).SetDBusInterface)(self, aDBusInterface) } /// ```text /// /** /// * Method defines the dbus method that should be invoked to handle this /// * protocol. If its not set, NS_ERROR_FAILURE will be returned by /// * LaunchWithURI /// */ /// ``` /// /// `attribute AUTF8String method;` #[inline] pub unsafe fn GetMethod(&self, aMethod: &mut ::nsstring::nsACString) -> nsresult { ((*self.vtable).GetMethod)(self, aMethod) } /// ```text /// /** /// * Method defines the dbus method that should be invoked to handle this /// * protocol. If its not set, NS_ERROR_FAILURE will be returned by /// * LaunchWithURI /// */ /// ``` /// /// `attribute AUTF8String method;` #[inline] pub unsafe fn SetMethod(&self, aMethod: &::nsstring::nsACString) -> nsresult { ((*self.vtable).SetMethod)(self, aMethod) } }