Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: sdk/lib/core/resource.dart

Issue 1181663002: Add Resource class. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of dart.core;
6
7 /**
8 * A resource that can be read into the program.
9 *
10 * A resource is data that can be located using a URI and read into
sethladd 2015/06/11 12:50:13 Might want to specify that implementations much al
Lasse Reichstein Nielsen 2015/06/11 13:53:54 I moved that to the constructor, but it might be w
Lasse Reichstein Nielsen 2015/06/16 12:05:01 Done.
11 * the program at runtime.
12 */
13 abstract class Resource {
14 /**
15 * Creates a resource object with the given [uri] as location.
16 *
17 * The `uri` is a string containing a valid URI.
18 * If the string is not a valid URI, using any of the functions on
19 * the resource object will fail.
20 *
21 * The URI may be relative, in which case it will be resolved
22 * against [Uri.base] before being used.
23 *
24 * The URI may use the `package` scheme, which is always supported.
25 * Other schemes may also be supported where possible.
26 */
27 external const factory Resource(String uri);
28
29 /**
30 * The location `uri` of this resource.
31 *
32 * This is a [Uri] of the `uri` parameter given to the constructor.
33 * If the parameter was not a valid URI, reading `uri` may fail.
34 */
35 Uri get uri;
36
37 /** Read the resource content as a stream of bytes. */
38 Stream<List<int>> openRead();
39
40 /** Read the resource content. */
41 Future<List<int>> readAsBytes();
42
43 /**
44 * Read the resource content as a string.
45 *
46 * The content is decoded into a string using an [Encoding].
47 * If no other encoding is provided, it defaults to UTF-8.
48 */
49 Future<String> readAsString({Encoding encoding});
50 }
OLDNEW
« runtime/lib/internal_patch.dart ('K') | « sdk/lib/core/core_sources.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698