API reference
API reference
Select your platform
No SDKs available
No versions available

OVRResult Struct

Extends IEquatable< OVRResult< TStatus > >, IEquatable< OVRResult< TValue, TStatus > >
Represents the result of an operation.
Represents a result with a value of type TValue and a status code of type TStatus .
An OVRResult<TStatus> is effectively an enum but with some additional machinery to test for success and to distinguish between a real value and a default-initialized value. This is important because an enum constant of zero is often used to indicate Success.
Many asynchronous methods return an OVRResult, for example many OVRAnchor and OVRSpatialAnchor methods are asynchronous.
For results that also contain a value, see OVRResult<TValue, TStatus>.
Others
TStatus
The type of the status code.
Others
TValue
The type of the value.
TStatus
The type of the status code.
An OVRResult<TValue, TStatus> represents the result of an operation which may fail. If the operation succeeds (Success is true), then you can access the value using the Value property.
If the operation fails (Success is false), then the OVRResult does not have a value, and it is an error to access the Value property. In this case, the Status property will contain an error code.

Properties

Whether this OVRResult<TStatus> represents a successful result.
Whether this OVRResult<TValue, TStatus> represents a successful result.This must be true in order to access Value.
The status of the result.
The status could represent success (see Success) or a failure. If it is a failure, use this property to obtain more detailed error information. If the operation fails (Success is false), then the Status enum indicates a more specific reason for the failure.
Indicates whether the result has a value.
It is an error to access Value when this property is false.
The value of the result.
It is an error to access this property unless Success is true. See also TryGetValue.
Exceptions
InvalidOperationException
Thrown if Success is false.

Static Member Functions

Creates a new OVRResult<TStatus> with the specified status.
Parameters
status
The status of the result.
Returns
Returns a new OVRResult<TStatus> with the specified status.
Creates a new OVRResult<TStatus> with the specified success status.
Parameters
status
The status (must be a valid success status).
Returns
Returns a new OVRResult<TStatus> with the specified status.
Exceptions
ArgumentException
Thrown when status is not a valid success status.
See Also
Creates a new OVRResult<TStatus> with the specified failure status.
Parameters
status
The status (must be a valid failure status).
Returns
Returns a new OVRResult<TStatus> with the specified status.
Exceptions
ArgumentException
Thrown when status is not a valid failure status.
See Also
Implicitly casts an OVRResult to a bool.
If the OVRResult represents success, then it will convert to true. Otherwise, it will convert to false. For example, this allows you to write code like:
var result = DoOperation();
if (result) {
  Debug.Log("Operation succeeded.");
} else {
  Debug.LogError($"Operation failed with error {result.Status}.");
}
Parameters
value
The OVRResult to cast.
Returns
Returns the value of Success.
(Internal) Implicitly converts an OVRPlugin.Result to an OVRResult<TStatus>.
This implicit conversion is provided mostly for internal Meta use (C# requires user-defined conversion operators to be public). It simplifies early returns in methods that return an OVRResult<TStatus> and need to early out when a call fails.Such methods can simply return the result rather than constructing an OVRResult<TStatus> with a cast.
Parameters
result
The result.
Returns
Returns an OVRResult<TStatus> whose Status is result cast to a TStatus .
Creates a new OVRResult<TValue, TStatus> with the specified value and status.
Parameters
value
The value.
status
The status.
Returns
Returns a new OVRResult<TValue, TStatus> with the specified value and status.
Creates a new OVRResult<TValue, TStatus> with the specified value and a success status.
Parameters
value
The value.
status
The status (must be a valid success status).
Returns
Returns a new OVRResult<TValue, TStatus> with the specified value and status.
Exceptions
ArgumentException
Thrown when status is not a valid success status.
See Also
Creates a new OVRResult<TValue, TStatus> with the specified failure status.
Parameters
status
The status (must be a valid failure status).
Returns
Returns a new OVRResult<TValue, TStatus> with the specified status.
Exceptions
ArgumentException
Thrown when status is not a valid failure status.
See Also
Implicitly casts an OVRResult to a bool.
If the OVRResult represents success, then it will convert to true. Otherwise, it will convert to false. For example, this allows you to write code like:
var result = DoOperation();
if (result) {
  Debug.Log("Operation succeeded.");
} else {
  Debug.LogError($"Operation failed with error {result.Status}.");
}
Parameters
value
The OVRResult to cast.
Returns
Returns the value of Success.
(Internal) Implicitly converts an OVRPlugin.Result to a failed OVRResult<TValue,TStatus>.
This implicit conversion is provided mostly for internal Meta use (C# requires user-defined conversion operators to be public). It simplifies early returns in methods that return an OVRResult<TValue,TStatus> and need to early out when a call fails.Such methods can simply return the result rather than constructing an OVRResult<TValue,TStatus> with potentially complex type parameters.
Parameters
result
The result, which must represent failure (be less than zero).
Returns
Returns an OVRResult<TValue,TStatus> whose Success is false.
Exceptions
ArgumentException
Thrown if result does not represent a failure case.

Member Functions

Determines whether the current OVRResult<TStatus> is equal to another OVRResult<TStatus>.
Parameters
other
The OVRResult<TStatus> to compare with the current one.
Returns
Returns true if the specified OVRResult<TStatus> is equal to this OVRResult<TStatus>, otherwise false.
Determines whether the current OVRResult<TStatus> is equal to another object.
Parameters
obj
The object to compare with the current OVRResult<TStatus>.
Returns
Returns true if obj is of type OVRResult<TStatus> and is equal to this OVRResult<TStatus>, otherwise false.
Gets a hashcode suitable for use in a Dictionary or HashSet.
Returns
Returns a hashcode suitable for use in a Dictionary or HashSet.
Generates a string representation of this result object.
The string representation is the stringification of Status, or "(invalid result)" if this result object has not been initialized.
Returns
Returns a string representation of this OVRResult<TStatus>
Tries to retrieve the value of the result.
This provides an exception-free method of obtaining the result's Value if one is available. This allows you to simplify your code. Instead of this:
if (result.HasValue) {
  var value = result.Value;
// use value
}
You can instead combine the HasValue check with the extraction of the result:
if (result.TryGetValue(out var value)) {
// use value
}
Parameters
value
When this method returns, contains the value of the result if the result was successful; otherwise, the default value.
Returns
Returns true if the result was successful and the value is retrieved; otherwise, false.
Determines whether the current OVRResult<TValue, TStatus> is equal to another OVRResult<TValue, TStatus>.
Parameters
other
The OVRResult<TValue, TStatus> to compare with the current one.
Returns
Returns true if the specified OVRResult<TValue, TStatus> is equal to the current OVRResult<TValue, TStatus>; otherwise, false.
Determines whether the current OVRResult<TValue, TStatus> is equal to another object.
Parameters
obj
The object to compare with the current OVRResult<TValue, TStatus>.
Returns
Returns true if the specified object is equal to the current OVRResult<TValue, TStatus>; otherwise, false.
override bool TStatus other && Equals
( other )
Gets a hashcode suitable for use in a Dictionary or HashSet.
Returns
Returns a hashcode for this result.
Generates a string representation of this result object.
If this result object has not been initialized, the string is "(invalid result)". Otherwise, if Success is true, then the string is the stringification of the Status and Value. If Success is false, then it is just the stringification of Status.
Returns
Returns a string representation of this OVRResult<TStatus>
Did you find this page helpful?
Thumbs up icon
Thumbs down icon