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
// // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIZipWriter.idl // /// `interface nsIZipWriter : nsISupports` /// /// ```text /// /** /// * nsIZipWriter /// * /// * An interface for a zip archiver that can be used from script. /// * /// * The interface supports both a synchronous method of archiving data and a /// * queueing system to allow operations to be prepared then run in sequence /// * with notification after completion. /// * /// * Operations added to the queue do not get performed until performQueue is /// * called at which point they will be performed in the order that they were /// * added to the queue. /// * /// * Operations performed on the queue will throw any errors out to the /// * observer. /// * /// * An attempt to perform a synchronous operation while the background queue /// * is in progress will throw NS_ERROR_IN_PROGRESS. /// * /// * Entry names should use /'s as path separators and should not start with /// * a /. /// * /// * It is not generally necessary to add directory entries in order to add file /// * entries within them, however it is possible that some zip programs may /// * experience problems what that. /// */ /// ``` /// // 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 nsIZipWriter { vtable: *const nsIZipWriterVTable, /// 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 nsIZipWriter. unsafe impl XpCom for nsIZipWriter { const IID: nsIID = nsID(0x3ca10750, 0x797e, 0x4a22, [0xbc, 0xfe, 0x66, 0x17, 0x0b, 0x5e, 0x96, 0xdd]); } // 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 nsIZipWriter { #[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 nsIZipWriter. // 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 nsIZipWriterCoerce { /// Cheaply cast a value of this type from a `nsIZipWriter`. fn coerce_from(v: &nsIZipWriter) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIZipWriterCoerce for nsIZipWriter { #[inline] fn coerce_from(v: &nsIZipWriter) -> &Self { v } } impl nsIZipWriter { /// Cast this `nsIZipWriter` to one of its base interfaces. #[inline] pub fn coerce<T: nsIZipWriterCoerce>(&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 nsIZipWriter { 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> nsIZipWriterCoerce for T { #[inline] fn coerce_from(v: &nsIZipWriter) -> &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 nsIZipWriter // 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 nsIZipWriterVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* attribute ACString comment; */ pub GetComment: unsafe extern "system" fn (this: *const nsIZipWriter, aComment: &mut ::nsstring::nsACString) -> nsresult, /* attribute ACString comment; */ pub SetComment: unsafe extern "system" fn (this: *const nsIZipWriter, aComment: &::nsstring::nsACString) -> nsresult, /* readonly attribute boolean inQueue; */ pub GetInQueue: unsafe extern "system" fn (this: *const nsIZipWriter, aInQueue: *mut bool) -> nsresult, /* readonly attribute nsIFile file; */ pub GetFile: unsafe extern "system" fn (this: *const nsIZipWriter, aFile: *mut *const nsIFile) -> nsresult, /* void open (in nsIFile aFile, in int32_t aIoFlags); */ pub Open: unsafe extern "system" fn (this: *const nsIZipWriter, aFile: *const nsIFile, aIoFlags: int32_t) -> nsresult, /* nsIZipEntry getEntry (in AUTF8String aZipEntry); */ pub GetEntry: unsafe extern "system" fn (this: *const nsIZipWriter, aZipEntry: &::nsstring::nsACString, _retval: *mut *const nsIZipEntry) -> nsresult, /* boolean hasEntry (in AUTF8String aZipEntry); */ pub HasEntry: unsafe extern "system" fn (this: *const nsIZipWriter, aZipEntry: &::nsstring::nsACString, _retval: *mut bool) -> nsresult, /* void addEntryDirectory (in AUTF8String aZipEntry, in PRTime aModTime, in boolean aQueue); */ pub AddEntryDirectory: unsafe extern "system" fn (this: *const nsIZipWriter, aZipEntry: &::nsstring::nsACString, aModTime: PRTime, aQueue: bool) -> nsresult, /* void addEntryFile (in AUTF8String aZipEntry, in int32_t aCompression, in nsIFile aFile, in boolean aQueue); */ pub AddEntryFile: unsafe extern "system" fn (this: *const nsIZipWriter, aZipEntry: &::nsstring::nsACString, aCompression: int32_t, aFile: *const nsIFile, aQueue: bool) -> nsresult, /* void addEntryChannel (in AUTF8String aZipEntry, in PRTime aModTime, in int32_t aCompression, in nsIChannel aChannel, in boolean aQueue); */ pub AddEntryChannel: unsafe extern "system" fn (this: *const nsIZipWriter, aZipEntry: &::nsstring::nsACString, aModTime: PRTime, aCompression: int32_t, aChannel: *const nsIChannel, aQueue: bool) -> nsresult, /* void addEntryStream (in AUTF8String aZipEntry, in PRTime aModTime, in int32_t aCompression, in nsIInputStream aStream, in boolean aQueue); */ pub AddEntryStream: unsafe extern "system" fn (this: *const nsIZipWriter, aZipEntry: &::nsstring::nsACString, aModTime: PRTime, aCompression: int32_t, aStream: *const nsIInputStream, aQueue: bool) -> nsresult, /* void removeEntry (in AUTF8String aZipEntry, in boolean aQueue); */ pub RemoveEntry: unsafe extern "system" fn (this: *const nsIZipWriter, aZipEntry: &::nsstring::nsACString, aQueue: bool) -> nsresult, /* void processQueue (in nsIRequestObserver aObserver, in nsISupports aContext); */ pub ProcessQueue: unsafe extern "system" fn (this: *const nsIZipWriter, aObserver: *const nsIRequestObserver, aContext: *const nsISupports) -> nsresult, /* void close (); */ pub Close: unsafe extern "system" fn (this: *const nsIZipWriter) -> nsresult, /* void alignStoredFiles (in uint16_t aAlignSize); */ pub AlignStoredFiles: unsafe extern "system" fn (this: *const nsIZipWriter, aAlignSize: uint16_t) -> nsresult, } // The implementations of the function wrappers which are exposed to rust code. // Call these methods rather than manually calling through the VTable struct. impl nsIZipWriter { /// ```text /// /** /// * Some predefined compression levels /// */ /// ``` /// pub const COMPRESSION_NONE: i64 = 0; pub const COMPRESSION_FASTEST: i64 = 1; pub const COMPRESSION_DEFAULT: i64 = 6; pub const COMPRESSION_BEST: i64 = 9; /// ```text /// /** /// * Gets or sets the comment associated with the open zip file. /// * /// * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened /// */ /// ``` /// /// `attribute ACString comment;` #[inline] pub unsafe fn GetComment(&self, aComment: &mut ::nsstring::nsACString) -> nsresult { ((*self.vtable).GetComment)(self, aComment) } /// ```text /// /** /// * Gets or sets the comment associated with the open zip file. /// * /// * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened /// */ /// ``` /// /// `attribute ACString comment;` #[inline] pub unsafe fn SetComment(&self, aComment: &::nsstring::nsACString) -> nsresult { ((*self.vtable).SetComment)(self, aComment) } /// ```text /// /** /// * Indicates that operations on the background queue are being performed. /// */ /// ``` /// /// `readonly attribute boolean inQueue;` #[inline] pub unsafe fn GetInQueue(&self, aInQueue: *mut bool) -> nsresult { ((*self.vtable).GetInQueue)(self, aInQueue) } /// ```text /// /** /// * The file that the zipwriter is writing to. /// */ /// ``` /// /// `readonly attribute nsIFile file;` #[inline] pub unsafe fn GetFile(&self, aFile: *mut *const nsIFile) -> nsresult { ((*self.vtable).GetFile)(self, aFile) } /// ```text /// /** /// * Opens a zip file. /// * /// * @param aFile the zip file to open /// * @param aIoFlags the open flags for the zip file from prio.h /// * /// * @throws NS_ERROR_ALREADY_INITIALIZED if a zip file is already open /// * @throws NS_ERROR_INVALID_ARG if aFile is null /// * @throws NS_ERROR_FILE_NOT_FOUND if aFile does not exist and flags did /// * not allow for creation /// * @throws NS_ERROR_FILE_CORRUPTED if the file does not contain zip markers /// * @throws <other-error> on failure to open zip file (most likely corrupt /// * or unsupported form) /// */ /// ``` /// /// `void open (in nsIFile aFile, in int32_t aIoFlags);` #[inline] pub unsafe fn Open(&self, aFile: *const nsIFile, aIoFlags: int32_t) -> nsresult { ((*self.vtable).Open)(self, aFile, aIoFlags) } /// ```text /// /** /// * Returns a nsIZipEntry describing a specified zip entry or null if there /// * is no such entry in the zip file /// * /// * @param aZipEntry the path of the entry /// */ /// ``` /// /// `nsIZipEntry getEntry (in AUTF8String aZipEntry);` #[inline] pub unsafe fn GetEntry(&self, aZipEntry: &::nsstring::nsACString, _retval: *mut *const nsIZipEntry) -> nsresult { ((*self.vtable).GetEntry)(self, aZipEntry, _retval) } /// ```text /// /** /// * Checks whether the zipfile contains an entry specified by zipEntry. /// * /// * @param aZipEntry the path of the entry /// */ /// ``` /// /// `boolean hasEntry (in AUTF8String aZipEntry);` #[inline] pub unsafe fn HasEntry(&self, aZipEntry: &::nsstring::nsACString, _retval: *mut bool) -> nsresult { ((*self.vtable).HasEntry)(self, aZipEntry, _retval) } /// ```text /// /** /// * Adds a new directory entry to the zip file. If aZipEntry does not end with /// * "/" then it will be added. /// * /// * @param aZipEntry the path of the directory entry /// * @param aModTime the modification time of the entry in microseconds /// * @param aQueue adds the operation to the background queue. Will be /// * performed when processQueue is called. /// * /// * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened /// * @throws NS_ERROR_FILE_ALREADY_EXISTS if the path already exists in the /// * file /// * @throws NS_ERROR_IN_PROGRESS if another operation is currently in progress /// */ /// ``` /// /// `void addEntryDirectory (in AUTF8String aZipEntry, in PRTime aModTime, in boolean aQueue);` #[inline] pub unsafe fn AddEntryDirectory(&self, aZipEntry: &::nsstring::nsACString, aModTime: PRTime, aQueue: bool) -> nsresult { ((*self.vtable).AddEntryDirectory)(self, aZipEntry, aModTime, aQueue) } /// ```text /// /** /// * Adds a new file or directory to the zip file. If the specified file is /// * a directory then this will be equivalent to a call to /// * addEntryDirectory(aZipEntry, aFile.lastModifiedTime, aQueue) /// * /// * @param aZipEntry the path of the file entry /// * @param aCompression the compression level, 0 is no compression, 9 is best /// * @param aFile the file to get the data and modification time from /// * @param aQueue adds the operation to the background queue. Will be /// * performed when processQueue is called. /// * /// * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened /// * @throws NS_ERROR_FILE_ALREADY_EXISTS if the path already exists in the zip /// * @throws NS_ERROR_IN_PROGRESS if another operation is currently in progress /// * @throws NS_ERROR_FILE_NOT_FOUND if file does not exist /// */ /// ``` /// /// `void addEntryFile (in AUTF8String aZipEntry, in int32_t aCompression, in nsIFile aFile, in boolean aQueue);` #[inline] pub unsafe fn AddEntryFile(&self, aZipEntry: &::nsstring::nsACString, aCompression: int32_t, aFile: *const nsIFile, aQueue: bool) -> nsresult { ((*self.vtable).AddEntryFile)(self, aZipEntry, aCompression, aFile, aQueue) } /// ```text /// /** /// * Adds data from a channel to the zip file. If the operation is performed /// * on the queue then the channel will be opened asynchronously, otherwise /// * the channel must support being opened synchronously. /// * /// * @param aZipEntry the path of the file entry /// * @param aModTime the modification time of the entry in microseconds /// * @param aCompression the compression level, 0 is no compression, 9 is best /// * @param aChannel the channel to get the data from /// * @param aQueue adds the operation to the background queue. Will be /// * performed when processQueue is called. /// * /// * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened /// * @throws NS_ERROR_FILE_ALREADY_EXISTS if the path already exists in the zip /// * @throws NS_ERROR_IN_PROGRESS if another operation is currently in progress /// */ /// ``` /// /// `void addEntryChannel (in AUTF8String aZipEntry, in PRTime aModTime, in int32_t aCompression, in nsIChannel aChannel, in boolean aQueue);` #[inline] pub unsafe fn AddEntryChannel(&self, aZipEntry: &::nsstring::nsACString, aModTime: PRTime, aCompression: int32_t, aChannel: *const nsIChannel, aQueue: bool) -> nsresult { ((*self.vtable).AddEntryChannel)(self, aZipEntry, aModTime, aCompression, aChannel, aQueue) } /// ```text /// /** /// * Adds data from an input stream to the zip file. /// * /// * @param aZipEntry the path of the file entry /// * @param aModTime the modification time of the entry in microseconds /// * @param aCompression the compression level, 0 is no compression, 9 is best /// * @param aStream the input stream to get the data from /// * @param aQueue adds the operation to the background queue. Will be /// * performed when processQueue is called. /// * /// * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened /// * @throws NS_ERROR_FILE_ALREADY_EXISTS if the path already exists in the zip /// * @throws NS_ERROR_IN_PROGRESS if another operation is currently in progress /// */ /// ``` /// /// `void addEntryStream (in AUTF8String aZipEntry, in PRTime aModTime, in int32_t aCompression, in nsIInputStream aStream, in boolean aQueue);` #[inline] pub unsafe fn AddEntryStream(&self, aZipEntry: &::nsstring::nsACString, aModTime: PRTime, aCompression: int32_t, aStream: *const nsIInputStream, aQueue: bool) -> nsresult { ((*self.vtable).AddEntryStream)(self, aZipEntry, aModTime, aCompression, aStream, aQueue) } /// ```text /// /** /// * Removes an existing entry from the zip file. /// * /// * @param aZipEntry the path of the entry to be removed /// * @param aQueue adds the operation to the background queue. Will be /// * performed when processQueue is called. /// * /// * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened /// * @throws NS_ERROR_IN_PROGRESS if another operation is currently in progress /// * @throws NS_ERROR_FILE_NOT_FOUND if no entry with the given path exists /// * @throws <other-error> on failure to update the zip file /// */ /// ``` /// /// `void removeEntry (in AUTF8String aZipEntry, in boolean aQueue);` #[inline] pub unsafe fn RemoveEntry(&self, aZipEntry: &::nsstring::nsACString, aQueue: bool) -> nsresult { ((*self.vtable).RemoveEntry)(self, aZipEntry, aQueue) } /// ```text /// /** /// * Processes all queued items until complete or some error occurs. The /// * observer will be notified when the first operation starts and when the /// * last operation completes. Any failures will be passed to the observer. /// * The zip writer will be busy until the queue is complete or some error /// * halted processing of the queue early. In the event of an early failure, /// * remaining items will stay in the queue and calling processQueue will /// * continue. /// * /// * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened /// * @throws NS_ERROR_IN_PROGRESS if the queue is already in progress /// */ /// ``` /// /// `void processQueue (in nsIRequestObserver aObserver, in nsISupports aContext);` #[inline] pub unsafe fn ProcessQueue(&self, aObserver: *const nsIRequestObserver, aContext: *const nsISupports) -> nsresult { ((*self.vtable).ProcessQueue)(self, aObserver, aContext) } /// ```text /// /** /// * Closes the zip file. /// * /// * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened /// * @throws NS_ERROR_IN_PROGRESS if another operation is currently in progress /// * @throws <other-error> on failure to complete the zip file /// */ /// ``` /// /// `void close ();` #[inline] pub unsafe fn Close(&self, ) -> nsresult { ((*self.vtable).Close)(self, ) } /// ```text /// /** /// * Make all stored(uncompressed) files align to given alignment size. /// * /// * @param aAlignSize is the alignment size, valid values from 2 to 32768, and /// must be power of 2. /// * /// * @throws NS_ERROR_INVALID_ARG if aAlignSize is invalid /// * @throws <other-error> on failure to update the zip file /// */ /// ``` /// /// `void alignStoredFiles (in uint16_t aAlignSize);` #[inline] pub unsafe fn AlignStoredFiles(&self, aAlignSize: uint16_t) -> nsresult { ((*self.vtable).AlignStoredFiles)(self, aAlignSize) } }