1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
use ;
use Resource;
use Serialize;
use DeserializeOwned;
use Debug;
/// Core Kubernetes resource abstraction used across `koprs`.
///
/// `KubeResource` represents the minimal set of capabilities required
/// for a type to be safely used with generic Kubernetes operations such as
/// apply, delete, list, and serialization.
///
/// This trait is automatically implemented for any type that satisfies the
/// required bounds.
///
/// It does **not** encode whether a resource is cluster-scoped or
/// namespaced-scoped. Scope is handled by [`NamespacedResource`] and
/// [`ClusterResource`].
///
/// # Purpose
///
/// This trait exists to:
/// - Eliminate repetitive generic bounds
/// - Standardize Kubernetes resource constraints across the crate
/// - Ensure all resources are safe for async controller usage
///
/// # Non-goals
///
/// This trait does not:
/// - Encode resource scope
/// - Provide runtime behavior
/// - Restrict Kubernetes API usage surface
///
/// # Examples
///
/// ```no_run
/// use koprs::traits::KubeResource;
/// use k8s_openapi::api::core::v1::Pod;
///
/// fn assert_kube_resource<T: KubeResource>() {}
///
/// assert_kube_resource::<Pod>();
/// ```
/// Marker trait for Kubernetes resources that are **namespaced-scoped**.
///
/// This trait guarantees that the resource can only be used with APIs that
/// require a namespace (e.g. `Api::namespaced`).
///
/// It enforces at compile time that:
/// - `T::Scope = NamespaceResourceScope`
///
/// # Why this exists
///
/// Without this trait, generic resource utilities cannot safely determine
/// whether a Kubernetes resource supports namespace-scoped operations.
///
/// This prevents accidental misuse such as attempting to call:
/// - namespaced APIs on cluster-scoped resources
///
/// # Examples
///
/// ```no_run
/// use koprs::traits::NamespacedResource;
/// use k8s_openapi::api::core::v1::Pod;
///
/// fn assert_namespaced<T: NamespacedResource>() {}
///
/// assert_namespaced::<Pod>();
/// ```
/// Marker trait for Kubernetes resources that are **cluster-scoped**.
///
/// This trait guarantees that the resource can only be used with cluster-level
/// APIs such as `Api::all`.
///
/// It enforces at compile time that:
/// - `T::Scope = ClusterResourceScope`
///
/// # Why this exists
///
/// Cluster-scoped resources (e.g. Nodes, ClusterRoles) cannot be addressed
/// within a namespace. This trait prevents accidental misuse of namespaced
/// APIs.
///
/// # Examples
///
/// ```no_run
/// use koprs::traits::ClusterResource;
/// use k8s_openapi::api::rbac::v1::ClusterRole;
///
/// fn assert_cluster<T: ClusterResource>() {}
///
/// assert_cluster::<ClusterRole>();
/// ```