|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nsISupports.idl" |
|
7 |
|
8 interface nsIInputStream; |
|
9 |
|
10 /** |
|
11 * nsIScriptableBase64Encoder efficiently encodes the contents |
|
12 * of a nsIInputStream to a Base64 string. This avoids the need |
|
13 * to read the entire stream into a buffer, and only then do the |
|
14 * Base64 encoding. |
|
15 * |
|
16 * If you already have a buffer full of data, you should use |
|
17 * btoa instead! |
|
18 */ |
|
19 [scriptable, uuid(9479c864-d1f9-45ab-b7b9-28b907bd2ba9)] |
|
20 interface nsIScriptableBase64Encoder : nsISupports |
|
21 { |
|
22 /** |
|
23 * These methods take an nsIInputStream and return a narrow or wide |
|
24 * string with the contents of the nsIInputStream base64 encoded. |
|
25 * |
|
26 * The stream passed in must support ReadSegments and must not be |
|
27 * a non-blocking stream that will return NS_BASE_STREAM_WOULD_BLOCK. |
|
28 * If either of these restrictions are violated we will abort. |
|
29 */ |
|
30 ACString encodeToCString(in nsIInputStream stream, in unsigned long length); |
|
31 AString encodeToString(in nsIInputStream stream, in unsigned long length); |
|
32 }; |