/
IValueStore.cs
64 lines (61 loc) · 2.4 KB
/
IValueStore.cs
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Ipfs.CoreApi
{
/// <summary>
/// A basic Put/Get interface.
/// </summary>
public interface IValueStore
{
/// <summary>
/// Gets th value of a key.
/// </summary>
/// <param name="key">
/// A byte array representing the name of a key.
/// </param>
/// <param name="cancel">
/// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
/// </param>
/// <returns>
/// A task that represents the asynchronous operation that returns
/// the value of the key as a byte array.
/// </returns>
Task<byte[]> GetAsync(byte[] key, CancellationToken cancel = default(CancellationToken));
/// <summary>
/// Tries to get the value of a key.
/// </summary>
/// <param name="key">
/// A byte array representing the name of a key.
/// </param>
/// <param name="value">
/// A byte array containing the value of the <paramref name="key"/>
/// </param>
/// <param name="cancel">
/// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
/// </param>
/// <returns>
/// A task that represents the asynchronous operation that returns
/// <b>true</b> if the key exists; otherwise, <b>false</b>.
/// </returns>
Task<bool> TryGetAsync(byte[] key, out byte[] value, CancellationToken cancel = default(CancellationToken));
/// <summary>
/// Put the value of a key.
/// </summary>
/// <param name="key">
/// A byte array representing the name of a key.
/// </param>
/// <param name="value">
/// A byte array containing the value of the <paramref name="key"/>
/// </param>
/// <param name="cancel">
/// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
/// </param>
/// <returns>
/// A task that represents the asynchronous operation.
/// </returns>
Task PutAsync(byte[] key, out byte[] value, CancellationToken cancel = default(CancellationToken));
}
}