Struct jsonrpsee_core::server::resource_limiting::Resources   
source · pub struct Resources {
    pub capacities: ResourceTable,
    pub defaults: ResourceTable,
    pub labels: ResourceVec<&'static str>,
    /* private fields */
}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: ResourceTableMax capacity for all resource kinds
defaults: ResourceTableDefault 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.