pub enum Resource {
Fd(Fd),
Process(Process),
None,
}
Expand description
Unified resource identifier for all trackable entities in the system.
Resources represent any entity that can participate in data flows within the traceability system. This includes file descriptors (which may point to files or streams), processes, or null resources for uninitialized states.
Variants§
Fd(Fd)
File descriptor resource (file or stream)
Process(Process)
Process resource
None
Null or uninitialized resource
Implementations§
Source§impl Resource
impl Resource
Sourcepub fn new_file(path: String) -> Self
pub fn new_file(path: String) -> Self
Creates a new file resource with the specified filesystem path.
The path is stored as provided without validation or normalization. Applications should provide valid paths to ensure proper resource tracking.
Sourcepub fn new_stream(local_socket: String, peer_socket: String) -> Self
pub fn new_stream(local_socket: String, peer_socket: String) -> Self
Creates a new stream resource with the specified socket addresses.
Both local and peer socket addresses should be valid network addresses in the format appropriate for the protocol (e.g., “IP:port” for TCP).
Sourcepub fn new_process(pid: i32) -> Self
pub fn new_process(pid: i32) -> Self
Creates a new process resource by querying the system for process information.
Attempts to retrieve the process start time and executable path from the system process table. If the process is not found, creates a process resource with default values for the metadata fields.
Sourcepub fn new_process_mock(pid: i32) -> Self
pub fn new_process_mock(pid: i32) -> Self
Creates a mock process resource for testing purposes.
Creates a process resource with the specified PID but default values for start time and executable path. Should only be used in test environments where system process queries are not needed.
Sourcepub fn is_file(&self) -> bool
pub fn is_file(&self) -> bool
Checks if this resource represents a filesystem file.
Returns true if the resource is a file descriptor pointing to a file, false for streams, processes, or null resources.
Sourcepub fn is_stream(&self) -> Option<Self>
pub fn is_stream(&self) -> Option<Self>
Returns the reverse stream resource if this is a stream resource.
For stream resources, returns a new resource with the local and peer socket addresses swapped. This is useful for tracking bidirectional flows. Returns None for non-stream resources.
Sourcepub fn is_process(&self) -> bool
pub fn is_process(&self) -> bool
Checks if this resource represents a system process.
Returns true if the resource is a process, false for file descriptors or null resources.
Trait Implementations§
impl Eq for Resource
impl StructuralPartialEq for Resource
Auto Trait Implementations§
impl Freeze for Resource
impl RefUnwindSafe for Resource
impl Send for Resource
impl Sync for Resource
impl Unpin for Resource
impl UnwindSafe for Resource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered
].