DropBear.Codex.Core
2024.6.2
See the version list below for details.
dotnet add package DropBear.Codex.Core --version 2024.6.2
NuGet\Install-Package DropBear.Codex.Core -Version 2024.6.2
<PackageReference Include="DropBear.Codex.Core" Version="2024.6.2" />
paket add DropBear.Codex.Core --version 2024.6.2
#r "nuget: DropBear.Codex.Core, 2024.6.2"
// Install DropBear.Codex.Core as a Cake Addin #addin nuget:?package=DropBear.Codex.Core&version=2024.6.2 // Install DropBear.Codex.Core as a Cake Tool #tool nuget:?package=DropBear.Codex.Core&version=2024.6.2
Result Class Library
This library provides a set of tools for managing operation results in a robust and railway-oriented programming fashion. It offers various result types to encapsulate the outcomes of operations, handling both successes and failures gracefully without throwing exceptions. This approach enhances error handling, makes your codebase cleaner, and improves the maintainability of your applications.
Features
- Generic Result Types: Handle different data types and operations flexibly.
- Railway-Oriented Programming: Built-in methods for chaining operations based on success or failure outcomes.
- Error Handling: Advanced error handling capabilities without relying on exceptions.
- Asynchronous Support: Asynchronous methods to handle I/O-bound and CPU-intensive operations efficiently.
Installation
To install the Result Class Library, use the following NuGet command:
dotnet add package DropBear.Codex.Core
Usage Examples
Below are some examples of how to use the various result types provided by the library:
Using Result
var result = Result.Success();
if (result.IsSuccess)
{
Console.WriteLine("Operation succeeded.");
}
var failureResult = Result.Failure("Error occurred.");
failureResult.OnFailure(error => Console.WriteLine(error));
Using Result<T>
var result = Result.Success(123);
var nextResult = result.Bind(value => Result.Success(value.ToString()));
nextResult.OnSuccess(value => Console.WriteLine($"Processed value: {value}"));
Using Result<TSuccess, TFailure>
var result = Result.Success<int, string>(42);
result.Match(
success => Console.WriteLine($"Success with value: {success}"),
failure => Console.WriteLine($"Failed with error: {failure}")
);
Using Result<TSuccess, TFailure>
with Additional Handlers
var result = Result.Success<int, string>(42);
result.Match(
success => Console.WriteLine($"Success with value: {success}"),
failure => Console.WriteLine($"Failed with error: {failure}"),
onPending: () => Console.WriteLine("Operation is pending."),
onCancelled: () => Console.WriteLine("Operation was cancelled."),
onWarning: () => Console.WriteLine("Operation completed with warnings."),
onPartialSuccess: () => Console.WriteLine("Operation partially succeeded."),
onNoOp: () => Console.WriteLine("No operation was performed.")
);
Using ResultWithPayload<T>
var data = new { Name = "Example", Value = 42 };
var result = Result.SuccessWithPayload(data);
var deserialized = result.DecompressAndDeserialize();
if (deserialized.IsSuccess)
{
Console.WriteLine($"Data: {deserialized.Value.Name}");
}
Contributing
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the GNU LGPL v3. See LICENSE for more information.
Contact
Terrence Kuchel (DropBear) - Contact me via GitHub. Project Link: GitHub
Acknowledgements
- Thanks to all contributors who participate in this project.
- Special thanks to those who contribute to railway-oriented programming ideas and patterns.
Development Status
Note: This library is relatively new and under active development. While it is being developed with robustness and best practices in mind, it may still be evolving.
We encourage you to test thoroughly and contribute if possible before using this library in a production environment. The API and features may change as feedback is received and improvements are made. We appreciate your understanding and contributions to making this library better!
Please use the following link to report any issues or to contribute: GitHub Issues.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages (8)
Showing the top 5 NuGet packages that depend on DropBear.Codex.Core:
Package | Downloads |
---|---|
DropBear.Codex.Utilities
Provides utility classes and helpers for the DropBear.Codex ecosystem |
|
DropBear.Codex.StateManagement
Simplified state management and snapshot system for the DropBear Codex framework. |
|
DropBear.Codex.Serialization
Provides serialization and deserialization utilities for the DropBear.Codex ecosystem |
|
DropBear.Codex.Files
Provides file management and storage capabilities for the DropBear.Codex ecosystem |
|
DropBear.Codex.Hashing
Provides various hashing implementations and utilities for the DropBear.Codex ecosystem |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2024.11.5 | 137 | 11/12/2024 |
2024.9.44 | 163 | 9/20/2024 |
2024.9.43 | 174 | 9/16/2024 |
2024.9.42 | 156 | 9/16/2024 |
2024.9.32 | 158 | 9/13/2024 |
2024.9.25 | 181 | 9/11/2024 |
2024.9.1 | 166 | 9/8/2024 |
2024.8.54 | 176 | 9/6/2024 |
2024.8.36 | 163 | 9/2/2024 |
2024.7.1 | 136 | 7/24/2024 |
2024.6.2 | 173 | 6/19/2024 |
2024.5.9 | 186 | 5/19/2024 |
2024.5.8 | 107 | 5/19/2024 |
2024.5.6 | 266 | 5/4/2024 |
2024.5.5 | 113 | 5/4/2024 |
2024.5.4 | 138 | 5/4/2024 |
2024.5.3 | 61 | 5/3/2024 |
2024.5.2 | 74 | 5/3/2024 |
2024.5.1 | 75 | 5/3/2024 |
2024.4.8 | 347 | 4/30/2024 |
2024.4.5 | 581 | 4/17/2024 |
2024.4.4 | 117 | 4/16/2024 |
2024.4.3 | 107 | 4/16/2024 |
2024.4.1 | 173 | 4/13/2024 |
2024.3.13 | 369 | 3/28/2024 |
2024.3.12 | 178 | 3/21/2024 |
2024.3.11 | 193 | 3/16/2024 |
2024.3.10 | 124 | 3/16/2024 |
2024.3.9 | 116 | 3/15/2024 |
2024.3.6 | 128 | 3/15/2024 |
2024.3.5 | 126 | 3/13/2024 |
2024.3.4 | 167 | 3/11/2024 |
2024.3.1 | 130 | 3/2/2024 |
2024.2.34 | 141 | 2/26/2024 |
2024.2.31 | 126 | 2/26/2024 |
2024.2.30 | 164 | 2/22/2024 |
2024.2.25 | 153 | 2/21/2024 |