Table of Contents

Struct ReadAttempt<T>

Namespace
CStructSharp.Values
Assembly
CStructSharp.dll

The outcome of an awaitable TryReadValueAsync<T> (an out parameter cannot cross an await): either Value with Succeeded set, or the categorized Failure the throwing form would have raised. Cancellation and argument errors are not outcomes; they throw as they do everywhere else.

public readonly struct ReadAttempt<T> : IEquatable<ReadAttempt<T>>

Type Parameters

T

The requested value type.

Implements
Inherited Members

Constructors

ReadAttempt(bool, T?, CStructException?)

The outcome of an awaitable TryReadValueAsync<T> (an out parameter cannot cross an await): either Value with Succeeded set, or the categorized Failure the throwing form would have raised. Cancellation and argument errors are not outcomes; they throw as they do everywhere else.

public ReadAttempt(bool Succeeded, T? Value, CStructException? Failure)

Parameters

Succeeded bool

Whether the read produced a value.

Value T

The value when Succeeded is true; otherwise the default.

Failure CStructException

The read, path, or limit failure when Succeeded is false; otherwise null.

Properties

Failure

The read, path, or limit failure when Succeeded is false; otherwise null.

public CStructException? Failure { get; init; }

Property Value

CStructException

Succeeded

Whether the read produced a value.

public bool Succeeded { get; init; }

Property Value

bool

Value

The value when Succeeded is true; otherwise the default.

public T? Value { get; init; }

Property Value

T

Methods

Deconstruct(out bool, out T?, out CStructException?)

public void Deconstruct(out bool Succeeded, out T? Value, out CStructException? Failure)

Parameters

Succeeded bool
Value T
Failure CStructException

Equals(ReadAttempt<T>)

public bool Equals(ReadAttempt<T> other)

Parameters

other ReadAttempt<T>

Returns

bool

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string

Operators

operator ==(ReadAttempt<T>, ReadAttempt<T>)

public static bool operator ==(ReadAttempt<T> left, ReadAttempt<T> right)

Parameters

left ReadAttempt<T>
right ReadAttempt<T>

Returns

bool

operator !=(ReadAttempt<T>, ReadAttempt<T>)

public static bool operator !=(ReadAttempt<T> left, ReadAttempt<T> right)

Parameters

left ReadAttempt<T>
right ReadAttempt<T>

Returns

bool