Struct jsonrpsee_core::server::resource_limiting::Resources
source · pub struct Resources {
pub capacities: ResourceTable,
pub defaults: ResourceTable,
pub labels: ResourceVec<&'static str>,
/* private fields */
}
server
only.Expand description
User defined resources available to be used by calls on the JSON-RPC server.
Each of the 8 possible resource kinds, for instance “cpu”, “io”, “nanobots”,
store a maximum capacity
and a default. A value of 0
means no limits for the given resource.
Fields§
§capacities: ResourceTable
Max capacity for all resource kinds
defaults: ResourceTable
Default value for all resource kinds; unless a method has a resource limit defined, this is the cost of a call (0 means no default limit)
labels: ResourceVec<&'static str>
Labels for every registered resource
Implementations§
source§impl Resources
impl Resources
sourcepub fn register(
&mut self,
label: &'static str,
capacity: u16,
default: u16,
) -> Result<(), Error>
pub fn register( &mut self, label: &'static str, capacity: u16, default: u16, ) -> Result<(), Error>
Register a new resource kind. Errors if label
is already registered, or if the total number of
registered resources would exceed 8.
sourcepub fn claim(&self, units: ResourceTable) -> Result<ResourceGuard, Error>
pub fn claim(&self, units: ResourceTable) -> Result<ResourceGuard, Error>
Attempt to claim units
units for each resource, incrementing current totals.
If successful, returns a ResourceGuard
which decrements the totals by the same
amounts once dropped.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Resources
impl !RefUnwindSafe for Resources
impl Send for Resources
impl Sync for Resources
impl Unpin for Resources
impl !UnwindSafe for Resources
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,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)