pub struct Client<'b> { /* private fields */ }
Expand description
Wrapper around the opaque type that stores the ES client state.
Note: this implementation ignores the return value of es_delete_client
if you use Drop
,
use Client::delete()
instead if you want to check it.
This type is neither Send
nor Sync
because the client must be released on the same
thread it was created.
Implementations§
Source§impl Client<'_>
Public bindings to the underlying es_client_t
API.
impl Client<'_>
Public bindings to the underlying es_client_t
API.
Sourcepub fn new<'b, F>(handler: F) -> Result<Client<'b>, NewClientError>
pub fn new<'b, F>(handler: F) -> Result<Client<'b>, NewClientError>
Creates a new Client
.
Callers must respect the following requirement if they want this function to succeed:
- Have the necessary entitlement for Endpoint Security
- Have the user’s approval (TCC)
- Be running as root when launching the client (and while it is active)
- Not have previously reached the maximum number of connected clients
See es_new_client()
.
Sourcepub fn subscribe(
&mut self,
events: &[es_event_type_t],
) -> Result<(), ReturnError>
pub fn subscribe( &mut self, events: &[es_event_type_t], ) -> Result<(), ReturnError>
Subscribe the client to events
, without removing previous subscriptions.
§Panics
events
can contain at most u32::MAX
elements. This is a limitation of Apple’s API.
See es_subscribe
.
Sourcepub fn unsubscribe(
&mut self,
events: &[es_event_type_t],
) -> Result<(), ReturnError>
pub fn unsubscribe( &mut self, events: &[es_event_type_t], ) -> Result<(), ReturnError>
Unsubscribe the client from events
, without removing other subscriptions.
§Panics
events
can contain at most u32::MAX
elements. This is a limitation of Apple’s API.
See es_unsubscribe
.
Sourcepub fn unsubscribe_all(&mut self) -> Result<(), ReturnError>
pub fn unsubscribe_all(&mut self) -> Result<(), ReturnError>
Unsubscribe the client from all its current subscriptions.
See es_unsubscribe_all
.
Sourcepub fn subscriptions(&mut self) -> Result<Vec<es_event_type_t>, ReturnError>
pub fn subscriptions(&mut self) -> Result<Vec<es_event_type_t>, ReturnError>
List current subscriptions of client.
See es_subscriptions
.
Sourcepub fn respond_auth_result(
&mut self,
msg: &Message,
resp: es_auth_result_t,
cache: bool,
) -> Result<(), RespondError>
pub fn respond_auth_result( &mut self, msg: &Message, resp: es_auth_result_t, cache: bool, ) -> Result<(), RespondError>
Respond to an auth event.
Sourcepub fn respond_flags_result(
&mut self,
msg: &Message,
authorized_flags: u32,
cache: bool,
) -> Result<(), RespondError>
pub fn respond_flags_result( &mut self, msg: &Message, authorized_flags: u32, cache: bool, ) -> Result<(), RespondError>
Respong to an auth event that needs a flag response.
Sourcepub fn mute_process(&mut self, process: &AuditToken) -> Result<(), ReturnError>
pub fn mute_process(&mut self, process: &AuditToken) -> Result<(), ReturnError>
Fully mute the given process.
See es_mute_process
.
Sourcepub fn mute_process_events(
&mut self,
process: &AuditToken,
events: &[es_event_type_t],
) -> Result<(), ReturnError>
Available on crate feature macos_12_0_0
only.
pub fn mute_process_events( &mut self, process: &AuditToken, events: &[es_event_type_t], ) -> Result<(), ReturnError>
macos_12_0_0
only.Mute only some events for the given process.
Only available on macOS 12.0+.
Sourcepub fn unmute_process(
&mut self,
process: &AuditToken,
) -> Result<(), ReturnError>
pub fn unmute_process( &mut self, process: &AuditToken, ) -> Result<(), ReturnError>
Fully unmute the given process.
See es_unmute_process
.
Sourcepub fn unmute_process_events(
&mut self,
process: &AuditToken,
events: &[es_event_type_t],
) -> Result<(), ReturnError>
Available on crate feature macos_12_0_0
only.
pub fn unmute_process_events( &mut self, process: &AuditToken, events: &[es_event_type_t], ) -> Result<(), ReturnError>
macos_12_0_0
only.Unmute only some events for the given process.
Only available on macOS 12.0+.
Sourcepub fn muted_processes(&mut self) -> Result<Vec<AuditToken>, ReturnError>
pub fn muted_processes(&mut self) -> Result<Vec<AuditToken>, ReturnError>
List muted processes.
The returned AuditToken
are in the same state as they were passed in to
Self::mute_process()
and may not accuretly reflect the current state of the respective processes.
See es_muted_processes
.
Deprecated in macOS 12.0+
Sourcepub fn muted_processes_events(
&mut self,
) -> Result<Vec<MutedProcess>, ReturnError>
Available on crate feature macos_12_0_0
only.
pub fn muted_processes_events( &mut self, ) -> Result<Vec<MutedProcess>, ReturnError>
macos_12_0_0
only.List muted processes with additional informations
See es_muted_processes_events
.
Only available on macOS 12.0+.
Sourcepub fn mute_path(
&mut self,
path: &OsStr,
ty: es_mute_path_type_t,
) -> Result<(), ReturnError>
pub fn mute_path( &mut self, path: &OsStr, ty: es_mute_path_type_t, ) -> Result<(), ReturnError>
Mute a path for all event types.
See es_mute_path
.
§Note
The C function takes a const char * _Nonnull path
, which means it expects a nul-
terminated string. Since the functions to gather such paths give OsString
s (ex:
Self::muted_paths_events
), this method will truncate the given path
to the first