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
sourceimpl 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 !RefUnwindSafe for Resources
impl Send for Resources
impl Sync for Resources
impl Unpin for Resources
impl !UnwindSafe for Resources
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more