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

Side by Side Diff: pkg/barback/lib/src/asset.dart

Issue 261823008: Reorganize barback's source files. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: re-add barback/lib/src/internal_asset.dart Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « pkg/barback/lib/barback.dart ('k') | pkg/barback/lib/src/asset/asset.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, 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 library barback.asset;
6
7 import 'dart:async';
8 import 'dart:io';
9 import 'dart:convert';
10
11 import 'asset_id.dart';
12 import 'internal_asset.dart';
13
14 /// A blob of content.
15 ///
16 /// Assets may come from the file system, or as the output of a [Transformer].
17 /// They are identified by [AssetId].
18 ///
19 /// Custom implementations of [Asset] are not currently supported.
20 abstract class Asset {
21 /// The ID for this asset.
22 final AssetId id;
23
24 factory Asset.fromBytes(AssetId id, List<int> bytes) =>
25 new BinaryAsset(id, bytes);
26
27 factory Asset.fromFile(AssetId id, File file) =>
28 new FileAsset(id, file.path);
29
30 factory Asset.fromString(AssetId id, String content) =>
31 new StringAsset(id, content);
32
33 factory Asset.fromPath(AssetId id, String path) =>
34 new FileAsset(id, path);
35
36 factory Asset.fromStream(AssetId id, Stream<List<int>> stream) =>
37 new StreamAsset(id, stream);
38
39 /// Returns the contents of the asset as a string.
40 ///
41 /// If the asset was created from a [String] the original string is always
42 /// returned and [encoding] is ignored. Otherwise, the binary data of the
43 /// asset is decoded using [encoding], which defaults to [UTF8].
44 Future<String> readAsString({Encoding encoding});
45
46 /// Streams the binary contents of the asset.
47 ///
48 /// If the asset was created from a [String], this returns its UTF-8 encoding.
49 Stream<List<int>> read();
50 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/barback.dart ('k') | pkg/barback/lib/src/asset/asset.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698