ab ovo
This commit is contained in:
44
src/p2p/types.zig
Normal file
44
src/p2p/types.zig
Normal file
@@ -0,0 +1,44 @@
|
||||
//! P2P Core Types
|
||||
//!
|
||||
//! This module defines the fundamental types used throughout the P2P library,
|
||||
//! including state enums.
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
/// P2P library states
|
||||
pub const P2PState = enum(u8) {
|
||||
/// Library is not initialized
|
||||
Uninitialized = 0,
|
||||
/// Library is initialized but not running
|
||||
Initialized = 1,
|
||||
/// Library is starting up
|
||||
Starting = 2,
|
||||
/// Library is running and operational
|
||||
Running = 3,
|
||||
/// Library is stopping
|
||||
Stopping = 4,
|
||||
/// Library is stopped
|
||||
Stopped = 5,
|
||||
/// Library is in maintenance mode
|
||||
Maintenance = 6,
|
||||
/// Library has encountered an error
|
||||
Error = 7,
|
||||
};
|
||||
|
||||
// Tests
|
||||
test "P2PState: all enum values" {
|
||||
const states = [_]P2PState{
|
||||
.Uninitialized,
|
||||
.Initialized,
|
||||
.Starting,
|
||||
.Running,
|
||||
.Stopping,
|
||||
.Stopped,
|
||||
.Maintenance,
|
||||
.Error,
|
||||
};
|
||||
|
||||
for (states) |state| {
|
||||
try std.testing.expect(@intFromEnum(state) < 10);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user