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
|
// <copyright file="ISearchService.cs" company="slskd Team">
// Copyright (c) slskd Team. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see https://www.gnu.org/licenses/.
// </copyright>
namespace slskd.Search
{
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Soulseek;
/// <summary>
/// Handles the lifecycle and persistence of searches.
/// </summary>
public interface ISearchService
{
/// <summary>
/// Deletes the specified ssearch.
/// </summary>
/// <param name="search">The search to delete.</param>
/// <returns>The operation context.</returns>
Task DeleteAsync(Search search);
/// <summary>
/// Finds a single search matching the specified <paramref name="expression"/>.
/// </summary>
/// <param name="expression">The expression to use to match searches.</param>
/// <param name="includeResponses">A value indicating whether to include search responses in the result.</param>
/// <returns>The found search, or default if not found.</returns>
/// <exception cref="ArgumentException">Thrown when an expression is not supplied.</exception>
Task<Search> FindAsync(Expression<Func<Search, bool>> expression, bool includeResponses = false);
/// <summary>
/// Returns a list of all completed and in-progress searches, with responses omitted, matching the optional <paramref name="expression"/>.
/// </summary>
/// <param name="expression">An optional expression used to match searches.</param>
/// <returns>The list of searches matching the specified expression, or all searches if no expression is specified.</returns>
Task<List<Search>> ListAsync(Expression<Func<Search, bool>> expression = null);
/// <summary>
/// Performs a search for the specified <paramref name="query"/> and <paramref name="scope"/>.
/// </summary>
/// <param name="id">A unique identifier for the search.</param>
/// <param name="query">The search query.</param>
/// <param name="scope">The search scope.</param>
/// <param name="options">Search options.</param>
/// <returns>The completed search.</returns>
Task<Search> StartAsync(Guid id, SearchQuery query, SearchScope scope, SearchOptions options = null);
/// <summary>
/// Cancels the search matching the specified <paramref name="id"/>, if it is in progress.
/// </summary>
/// <param name="id">The unique identifier for the search.</param>
/// <returns>A value indicating whether the search was sucessfully cancelled.</returns>
bool TryCancel(Guid id);
}
}
|