-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaptureResult.cs
More file actions
32 lines (30 loc) · 1.13 KB
/
Copy pathCaptureResult.cs
File metadata and controls
32 lines (30 loc) · 1.13 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
namespace ThatCapture;
/// <summary>
/// The result of a screen capture operation. Either <see cref="Ok"/> or <see cref="Err"/>.
/// </summary>
/// <remarks>
/// Use pattern matching to access the value — there is no shared property that gives you
/// the frame or the error without first discriminating which case you have:
/// <code>
/// var result = await capture.CaptureAreaAsync(x, y, width, height);
///
/// if (result is CaptureResult.Ok(var frame))
/// {
/// // use frame.Pixels, frame.Width, etc.
/// }
///
/// // Or exhaustively with a switch expression:
/// string label = result switch
/// {
/// CaptureResult.Ok(var frame) => $"captured {frame.Width}x{frame.Height}",
/// CaptureResult.Err(var err) => $"failed: {err}",
/// };
/// </code>
/// </remarks>
public abstract record CaptureResult
{
/// <summary>The capture succeeded. Contains the captured <see cref="CapturedFrame"/>.</summary>
public sealed record Ok(CapturedFrame Frame) : CaptureResult;
/// <summary>The capture failed. Contains a <see cref="CaptureError"/> describing why.</summary>
public sealed record Err(CaptureError Error) : CaptureResult;
}