-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathIBObjectParser.cs
More file actions
83 lines (74 loc) · 3.33 KB
/
Copy pathIBObjectParser.cs
File metadata and controls
83 lines (74 loc) · 3.33 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
using System.IO;
using System.IO.Pipelines;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BencodeNET.IO;
using BencodeNET.Objects;
namespace BencodeNET.Parsing
{
/// <summary>
/// A contract for parsing bencode from different sources as an <see cref="IBObject"/>.
/// </summary>
public interface IBObjectParser
{
/// <summary>
/// The encoding used for parsing.
/// </summary>
Encoding Encoding { get; }
/// <summary>
/// Parses a stream into an <see cref="IBObject"/>.
/// </summary>
/// <param name="stream">The stream to parse.</param>
/// <returns>The parsed object.</returns>
IBObject Parse(Stream stream);
/// <summary>
/// Parses an <see cref="IBObject"/> from a <see cref="BencodeReader"/>.
/// </summary>
IBObject Parse(BencodeReader reader);
/// <summary>
/// Parses an <see cref="IBObject"/> from a <see cref="PipeReader"/>.
/// </summary>
/// <param name="pipeReader">The pipe reader to read from.</param>
/// <param name="cancellationToken"></param>
/// <returns>The parsed object.</returns>
ValueTask<IBObject> ParseAsync(PipeReader pipeReader, CancellationToken cancellationToken = default);
/// <summary>
/// Parses an <see cref="IBObject"/> from a <see cref="PipeBencodeReader"/>.
/// </summary>
/// <param name="pipeReader">The pipe reader to read from.</param>
/// <param name="cancellationToken"></param>
/// <returns>The parsed object.</returns>
ValueTask<IBObject> ParseAsync(PipeBencodeReader pipeReader, CancellationToken cancellationToken = default);
}
/// <summary>
/// A contract for parsing bencode from different sources as type <typeparamref name="T"/> inheriting <see cref="IBObject"/>.
/// </summary>
public interface IBObjectParser<T> : IBObjectParser where T : IBObject
{
/// <summary>
/// Parses a stream into an <see cref="IBObject"/> of type <typeparamref name="T"/>.
/// </summary>
/// <param name="stream">The stream to parse.</param>
/// <returns>The parsed object.</returns>
new T Parse(Stream stream);
/// <summary>
/// Parses an <see cref="IBObject"/> of type <typeparamref name="T"/> from a <see cref="BencodeReader"/>.
/// </summary>
new T Parse(BencodeReader reader);
/// <summary>
/// Parses an <see cref="IBObject"/> of type <typeparamref name="T"/> from a <see cref="PipeReader"/>.
/// </summary>
/// <param name="pipeReader">The pipe reader to read from.</param>
/// <param name="cancellationToken"></param>
/// <returns>The parsed object.</returns>
new ValueTask<T> ParseAsync(PipeReader pipeReader, CancellationToken cancellationToken = default);
/// <summary>
/// Parses an <see cref="IBObject"/> of type <typeparamref name="T"/> from a <see cref="PipeBencodeReader"/>.
/// </summary>
/// <param name="pipeReader">The pipe reader to read from.</param>
/// <param name="cancellationToken"></param>
/// <returns>The parsed object.</returns>
new ValueTask<T> ParseAsync(PipeBencodeReader pipeReader, CancellationToken cancellationToken = default);
}
}