45 lines
994 B
Zig
45 lines
994 B
Zig
//! 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);
|
|
}
|
|
}
|