// Copyright (c) Microsoft Corporation // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. namespace PowerToys.ModuleContracts; /// /// Lightweight result type for module operations. /// public readonly record struct OperationResult(bool Success, string? Error = null) { public static OperationResult Ok() => new(true, null); public static OperationResult Fail(string error) => new(false, error); } /// /// Result type with a payload. /// public readonly record struct OperationResult(bool Success, T? Value, string? Error = null); /// /// Factory helpers for creating operation results. /// public static class OperationResults { public static OperationResult Ok(T value) => new(true, value, null); public static OperationResult Fail(string error) => new(false, default, error); }