pub enum SysprimsError {
InvalidArgument {
message: String,
},
SpawnFailed {
source: Error,
},
Timeout,
PermissionDenied {
pid: u32,
operation: String,
},
NotFound {
pid: u32,
},
NotFoundCommand {
command: String,
},
PermissionDeniedCommand {
command: String,
},
PermissionDeniedPath {
path: String,
operation: String,
},
NotSupported {
feature: String,
platform: String,
},
GroupCreationFailed {
message: String,
},
System {
message: String,
errno: i32,
},
Internal {
message: String,
},
}Expand description
Canonical error type for all sysprims operations.
This is the single error type used across the sysprims ecosystem. It maps cleanly to FFI error codes and provides structured context for programmatic handling.
§FFI Error Code Mapping
| Variant | FFI Code |
|---|---|
InvalidArgument | SYSPRIMS_ERR_INVALID_ARGUMENT (1) |
SpawnFailed | SYSPRIMS_ERR_SPAWN_FAILED (2) |
Timeout | SYSPRIMS_ERR_TIMEOUT (3) |
PermissionDenied | SYSPRIMS_ERR_PERMISSION_DENIED (4) |
NotFound | SYSPRIMS_ERR_NOT_FOUND (5) |
NotSupported | SYSPRIMS_ERR_NOT_SUPPORTED (6) |
GroupCreationFailed | SYSPRIMS_ERR_GROUP_CREATION_FAILED (7) |
System | SYSPRIMS_ERR_SYSTEM (8) |
Internal | SYSPRIMS_ERR_INTERNAL (99) |
Variants§
InvalidArgument
Invalid argument provided.
Returned when input validation fails (e.g., pid = 0, empty command).
SpawnFailed
Failed to spawn a child process.
Wraps the underlying IO error from process creation.
Timeout
Operation timed out.
The child process did not complete within the deadline.
PermissionDenied
Permission denied for the operation.
Typically returned when signaling a process owned by another user.
Fields
NotFound
Target process not found.
The specified PID does not exist or has already exited.
NotFoundCommand
Command not found.
The specified command could not be found in PATH.
PermissionDeniedCommand
Permission denied for command execution.
The specified command exists but cannot be executed (e.g., not executable).
PermissionDeniedPath
Permission denied for a filesystem path.
Used when opening caller-provided paths such as nohup output targets.
Fields
NotSupported
Operation not supported on the current platform.
Some operations are platform-specific (e.g., killpg on Windows).
Fields
GroupCreationFailed
Failed to create process group or job object.
On Unix, this means setpgid() failed.
On Windows, this means Job Object creation failed.
System
System-level error with errno/GetLastError context.
Used when a syscall fails with an unexpected error code.
Fields
Internal
Internal error (should not happen in normal operation).
Indicates a bug in sysprims or unexpected system state.
Implementations§
Source§impl SysprimsError
impl SysprimsError
Sourcepub fn error_code(&self) -> i32
pub fn error_code(&self) -> i32
Get the FFI error code for this error.
Maps to SysprimsErrorCode enum in C-ABI.
Source§impl SysprimsError
impl SysprimsError
Sourcepub fn invalid_argument(message: impl Into<String>) -> Self
pub fn invalid_argument(message: impl Into<String>) -> Self
Create an InvalidArgument error.
Sourcepub fn spawn_failed_io(source: Error) -> Self
pub fn spawn_failed_io(source: Error) -> Self
Create a SpawnFailed error from an IO error.
Sourcepub fn permission_denied(pid: u32, operation: impl Into<String>) -> Self
pub fn permission_denied(pid: u32, operation: impl Into<String>) -> Self
Create a PermissionDenied error.
Sourcepub fn not_found_command(command: impl Into<String>) -> Self
pub fn not_found_command(command: impl Into<String>) -> Self
Create a NotFoundCommand error.
Sourcepub fn permission_denied_command(command: impl Into<String>) -> Self
pub fn permission_denied_command(command: impl Into<String>) -> Self
Create a PermissionDeniedCommand error.
Sourcepub fn permission_denied_path(
path: impl Into<String>,
operation: impl Into<String>,
) -> Self
pub fn permission_denied_path( path: impl Into<String>, operation: impl Into<String>, ) -> Self
Create a path-oriented permission denied error.
Sourcepub fn spawn_failed(
command: impl Into<String>,
reason: impl Into<String>,
) -> Self
pub fn spawn_failed( command: impl Into<String>, reason: impl Into<String>, ) -> Self
Create a SpawnFailed error with a command and reason.
Sourcepub fn not_supported(
feature: impl Into<String>,
platform: impl Into<String>,
) -> Self
pub fn not_supported( feature: impl Into<String>, platform: impl Into<String>, ) -> Self
Create a NotSupported error.
Sourcepub fn group_creation_failed(message: impl Into<String>) -> Self
pub fn group_creation_failed(message: impl Into<String>) -> Self
Create a GroupCreationFailed error.
Trait Implementations§
Source§impl Debug for SysprimsError
impl Debug for SysprimsError
Source§impl Display for SysprimsError
impl Display for SysprimsError
Source§impl Error for SysprimsError
impl Error for SysprimsError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()