OLD | NEW |
| (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 search_engine; | |
6 | |
7 import 'dart:async'; | |
8 import 'dart:convert' show JSON; | |
9 import 'dart:io' show HttpStatus; | |
10 import 'package:http/http.dart' as http_client; | |
11 | |
12 part 'github_search_engine.dart'; | |
13 part 'stack_overflow_search_engine.dart'; | |
14 | |
15 | |
16 /** | |
17 * A [SearchEngine] provides the ability to search for a given string. | |
18 */ | |
19 abstract class SearchEngine { | |
20 /** | |
21 * Get the name of the search engine. | |
22 */ | |
23 String get name; | |
24 | |
25 /** | |
26 * Perform a search for [input]. The returned [Stream] will complete | |
27 * when there are no more results. | |
28 */ | |
29 Stream<SearchResult> search(String input); | |
30 } | |
31 | |
32 | |
33 /** | |
34 * A [SearchResult] entry, returned by [SearchEngine.search]. | |
35 */ | |
36 class SearchResult { | |
37 /** | |
38 * The title of the result. | |
39 */ | |
40 final String title; | |
41 | |
42 /** | |
43 * The link of the result. | |
44 */ | |
45 final String link; | |
46 | |
47 /** | |
48 * Create a new [SearchResult] from a title and a link. | |
49 */ | |
50 SearchResult(this.title, this.link); | |
51 } | |
OLD | NEW |