forked from cloudevents/sdk-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ICloudEventFormatter.cs
64 lines (60 loc) · 2.47 KB
/
ICloudEventFormatter.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
// Copyright (c) Cloud Native Foundation.
// Licensed under the Apache 2.0 license.
// See LICENSE file in the project root for full license information.
namespace CloudNative.CloudEvents
{
using System.Collections.Generic;
using System.IO;
using System.Net.Mime;
using System.Threading.Tasks;
/// <summary>
/// Implemented by formatters
/// </summary>
public interface ICloudEventFormatter
{
/// <summary>
/// Decode a structured event from a stream
/// </summary>
/// <param name="data"></param>
/// <param name="extensions"></param>
/// <returns></returns>
CloudEvent DecodeStructuredEvent(Stream data, IEnumerable<ICloudEventExtension> extensions);
/// <summary>
/// Decode a structured event from a stream asynchonously
/// </summary>
/// <param name="data"></param>
/// <param name="extensions"></param>
/// <returns></returns>
Task<CloudEvent> DecodeStructuredEventAsync(Stream data, IEnumerable<ICloudEventExtension> extensions);
/// <summary>
/// Decode a structured event from a byte array
/// </summary>
/// <param name="data"></param>
/// <param name="extensions"></param>
/// <returns></returns>
CloudEvent DecodeStructuredEvent(byte[] data, IEnumerable<ICloudEventExtension> extensions);
/// <summary>
/// Encode an structured event into a byte array
/// </summary>
/// <param name="cloudEvent"></param>
/// <param name="contentType"></param>
/// <returns></returns>
byte[] EncodeStructuredEvent(CloudEvent cloudEvent, out ContentType contentType);
/// <summary>
/// Decode an attribute from a byte array
/// </summary>
/// <param name="name"></param>
/// <param name="data"></param>
/// <param name="extensions"></param>
/// <returns></returns>
object DecodeAttribute(CloudEventsSpecVersion specVersion, string name, byte[] data, IEnumerable<ICloudEventExtension> extensions);
/// <summary>
/// Encode an attribute into a byte array
/// </summary>
/// <param name="name"></param>
/// <param name="value"></param>
/// <param name="extensions"></param>
/// <returns></returns>
byte[] EncodeAttribute(CloudEventsSpecVersion specVersion, string name, object value, IEnumerable<ICloudEventExtension> extensions);
}
}