AsyncConversionStatus.cs
2.77 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
namespace UnityEngine.XR.ARSubsystems
{
public partial struct XRCpuImage
{
/// <summary>
/// Represents the status of an asynchronous camera image request.
/// </summary>
public enum AsyncConversionStatus
{
/// <summary>
/// The request is not valid or has been disposed.
/// </summary>
Disposed,
/// <summary>
/// The request is waiting to be processed.
/// </summary>
Pending,
/// <summary>
/// The request is currently being processed.
/// </summary>
Processing,
/// <summary>
/// The request succeeded and image data is ready.
/// </summary>
Ready,
/// <summary>
/// The request failed. No data is available.
/// </summary>
Failed
}
}
/// <summary>
/// Extension methods for the <see cref="XRCpuImage.AsyncConversionStatus"/> enum.
/// </summary>
public static class XRCpuImageAsyncConversionStatusExtensions
{
/// <summary>
/// Whether the request has completed. It may have completed with an error or be
/// an invalid / disposed request. See <see cref="IsError(XRCpuImage.AsyncConversionStatus)"/>.
/// </summary>
/// <param name="status">The <see cref="XRCpuImage.AsyncConversionStatus"/> being extended.</param>
/// <returns><c>true</c> if the <see cref="XRCpuImage.AsyncConversionStatus"/> has completed.</returns>
public static bool IsDone(this XRCpuImage.AsyncConversionStatus status)
{
switch (status)
{
case XRCpuImage.AsyncConversionStatus.Pending:
case XRCpuImage.AsyncConversionStatus.Processing:
return false;
default:
return true;
}
}
/// <summary>
/// Whether the request status represents an error. If the request has been disposed, <c>IsError</c>
/// will be <c>true</c>.
/// </summary>
/// <param name="status">The <see cref="XRCpuImage.AsyncConversionStatus"/> being extended.</param>
/// <returns><c>true</c> if the <see cref="XRCpuImage.AsyncConversionStatus"/> represents an error.</returns>
public static bool IsError(this XRCpuImage.AsyncConversionStatus status)
{
switch (status)
{
case XRCpuImage.AsyncConversionStatus.Pending:
case XRCpuImage.AsyncConversionStatus.Processing:
case XRCpuImage.AsyncConversionStatus.Ready:
return false;
default:
return true;
}
}
}
}