ResourceLimiter

Struct ResourceLimiter 

Source
pub struct ResourceLimiter { /* private fields */ }
Expand description

Resource limiter and enforcement engine.

Implementations§

Source§

impl ResourceLimiter

Source

pub const fn new() -> Self

Create a new resource limiter.

Source

pub fn init(&self) -> Result<(), &'static str>

Initialize the resource limiter.

Source

pub fn is_enabled(&self) -> bool

Check if resource limiting is enabled.

Source

pub fn set_default_quota(&self, quota: ResourceQuota)

Set the default quota for new threads.

Source

pub fn set_thread_quota(&self, thread_id: ThreadId, quota: ResourceQuota)

Set a custom quota for a specific thread.

Source

pub fn register_thread(&self, thread_id: ThreadId)

Register a new thread for resource tracking.

Source

pub fn unregister_thread(&self, thread_id: ThreadId)

Unregister a thread from resource tracking.

Source

pub fn check_resource_limit( &self, thread_id: ThreadId, resource_type: ResourceType, requested_amount: u64, ) -> Result<(), ThreadError>

Check if a resource allocation would violate limits.

Source

pub fn update_resource_usage( &self, thread_id: ThreadId, resource_type: ResourceType, new_value: u64, )

Update resource usage for a thread.

Source

pub fn set_violation_handler(&self, handler: fn(&LimitViolation))

Set violation handler callback.

Source

pub fn get_violation_history(&self) -> Vec<LimitViolation>

Get recent violation history.

Source

pub fn get_system_usage(&self) -> SystemResourceUsage

Get system resource usage summary.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.