Skip to main content

AeronCountersReader

Struct AeronCountersReader 

Source
pub struct AeronCountersReader<S: ResourceStorage<aeron_counters_reader_t> = LiveCResource<aeron_counters_reader_t>> { /* private fields */ }

Implementations§

Source§

impl<S: ResourceStorage<aeron_counters_reader_t>> AeronCountersReader<S>

Source

pub unsafe fn get_buffers_into( &self, buffers: &AeronCountersReaderBuffers<impl ResourceStorage<aeron_counters_reader_buffers_t>>, ) -> Result<i32, AeronCError>

Get buffer pointers and lengths for the counters reader.

§Parameters
  • buffers output structure to return the buffers.
§Return

-1 on failure, 0 on success.

§Safety

The output may contain borrowed native pointers. Do not use those pointers after the queried handle is dropped or changed. Prefer the lifetime-bound get_constants, get_buffers or get_values method.

Source

pub fn get_buffers( &self, ) -> Result<AeronCountersReaderBuffers<ScopedInline<'_, aeron_counters_reader_buffers_t>>, AeronCError>

Get buffer pointers and lengths for the counters reader.

Source

pub fn foreach_counter<AeronCountersReaderForeachCounterFuncHandlerImpl: AeronCountersReaderForeachCounterFuncCallback, AeronCountersReaderForeachCounterFuncHandlerImplPolicy: CallbackPolicy>( &self, func: &Handler<AeronCountersReaderForeachCounterFuncHandlerImpl, AeronCountersReaderForeachCounterFuncHandlerImplPolicy>, )

Iterate over the counters in the counters_reader and call the given function for each counter.

§Parameters
  • func to call for each counter.
Source

pub fn foreach_counter_fn<AeronCountersReaderForeachCounterFuncHandlerImpl: FnMut(i64, i32, i32, &[u8], &str)>( &self, func: AeronCountersReaderForeachCounterFuncHandlerImpl, )

Iterate over the counters in the counters_reader and call the given function for each counter.

§Parameters
  • func to call for each counter.

Stack-borrowed closure variant. The FnMut closure lives on the caller’s stack and is borrowed for this call only. The callback fires synchronously, so nothing is heap-allocated or stored and the closure may borrow local state. Generated only for callbacks C does not retain. Prefer it to the Handler form on the hot path

§Panics

A panic in the closure is caught so the C call can finish, then passed to the caller once it returns

Source

pub fn find_by_type_id_and_registration_id( &self, type_id: i32, registration_id: i64, ) -> i32

Iterate over allocated counters and find the first matching a given type id and registration id.

§Parameters
  • type_id to find.
  • registration_id to find.
§Return

the counter id if found otherwise AERON_NULL_COUNTER_ID.

Source

pub fn max_counter_id(&self) -> i32

Get the current max counter id.

§Return

-1 on failure, max counter id on success.

Source

pub fn addr(&self, counter_id: i32) -> *mut i64

Get the address for a counter.

§Parameters
  • counter_id to find
§Return

address of the counter value

Source

pub fn counter_registration_id( &self, counter_id: i32, ) -> Result<i64, AeronCError>

Get the registration id assigned to a counter.

§Parameters
  • counter_id for which the registration id is requested.
  • registration_id pointer for value to be set on success.
Source

pub fn counter_owner_id(&self, counter_id: i32) -> Result<i64, AeronCError>

Get the owner id assigned to a counter which will typically be the client id.

§Parameters
  • counter_id for which the owner id is requested.
  • owner_id pointer for value to be set on success.
Source

pub fn counter_reference_id(&self, counter_id: i32) -> Result<i64, AeronCError>

Get the reference id assigned to a counter which will typically be the registration id of an associated Image, Subscription, Publication, etc.

§Parameters
  • counter_id for which the reference id is requested.
  • reference_id pointer for value to be set on success.
Source

pub fn counter_state(&self, counter_id: i32) -> Result<i32, AeronCError>

Get the state for a counter.

§Parameters
  • counter_id to find
  • state out pointer for the current state to be stored in.
Source

pub fn counter_type_id(&self, counter_id: i32) -> Result<i32, AeronCError>

Get the type id for a counter.

§Parameters
  • counter_id to find
Source

pub fn counter_label( &self, counter_id: i32, buffer: &mut [u8], ) -> Result<i32, AeronCError>

Get the label for a counter.

§Parameters
  • counter_id to find
  • buffer to store the counter in.
§Return

-1 on failure, number of characters copied to buffer on success.

Source

pub fn free_for_reuse_deadline_ms( &self, counter_id: i32, ) -> Result<i64, AeronCError>

Get the free for reuse deadline (ms) for a counter.

§Parameters
  • counter_id to find.
  • deadline_ms output value to store the deadline.
Source

pub fn aeron_local_sockaddr_find_addrs( &self, channel_status_indicator_id: i32, address_vec: &AeronIovec, address_vec_len: usize, ) -> Result<i32, AeronCError>

Source

pub fn as_ref(&self) -> Ref<'_, Self>

Borrow this handle without cloning its owner.

Source

pub fn get_inner(&self) -> *mut aeron_counters_reader_t

Source

pub unsafe fn get_inner_mut(&self) -> &mut aeron_counters_reader_t

Mutable access to the underlying C struct, minted from &self: nothing prevents two live &mut at once, so the caller must ensure exclusive access for the lifetime of the returned reference.

§Safety

No other reference (& or &mut) to the underlying struct may be alive while the returned &mut is in use.

Source

pub unsafe fn get_inner_ref(&self) -> &aeron_counters_reader_t

Borrow the native struct.

§Safety

No Rust or native call may mutate the struct while this reference is alive. Shared wrappers also require coordination with other threads.

Source§

impl AeronCountersReader

Source

pub unsafe fn from_ptr( ptr: *mut aeron_counters_reader_t, ) -> AeronCountersReader<Borrowed<aeron_counters_reader_t>>

Borrow a native pointer without taking ownership.

§Safety

The pointer must be non-null. It and its parents must remain live for every use. Calls must follow Aeron’s threading and aliasing rules.

Source§

impl AeronCountersReader

Source

pub const MAX_KEY_LENGTH: usize

A counter key has 112 bytes, as in Java’s CountersReader.MAX_KEY_LENGTH.

Source§

impl<S: ResourceStorage<aeron_counters_reader_t>> AeronCountersReader<S>

Source

pub fn addr_atomic(&self, counter_id: i32) -> &AtomicI64

Atomic access to a counter value. The reader keeps its backing mapping alive.

Source

pub fn find_by_type_id<F: FnMut(&[u8]) -> bool>( &self, type_id: i32, predicate: F, ) -> Option<i32>

Find the first counter of type_id whose key matches predicate.

The type ids are the bindgen’d AERON_COUNTER_*_TYPE_ID constants; the key layout is type-specific (see aeron_counters.h). Mirrors Java’s CountersReader lookups.

Source

pub fn find_by_type_and_registration_id( &self, type_id: i32, registration_id: i64, ) -> Option<i32>

Find the first counter of type_id keyed by registration_id, the layout used by aeron’s per-stream counters (publisher limit/position, sender/receiver positions, subscriber position). The key starts with the registration id as a little-endian i64. Mirrors Java’s findCounterIdByRegistration-style helpers, e.g.:

let registration_id = publication.get_constants()?.registration_id;
let limit_counter = counters_reader
    .find_by_type_and_registration_id(AERON_COUNTER_PUBLISHER_LIMIT_TYPE_ID as i32, registration_id);
// or, typed
let limit_counter = counters_reader
    .find_by_counter_type_and_registration_id(AeronCounterTypeId::PublisherLimit, registration_id);
Source

pub fn find_by_counter_type( &self, counter_type: AeronCounterTypeId, predicate: impl FnMut(&[u8]) -> bool, ) -> Option<i32>

Self::find_by_type_id with a typed counter type

Source

pub fn find_by_counter_type_and_registration_id( &self, counter_type: AeronCounterTypeId, registration_id: i64, ) -> Option<i32>

Self::find_by_type_and_registration_id with a typed counter type, e.g. reader.find_by_counter_type_and_registration_id(AeronCounterTypeId::PublisherLimit, registration_id)

Source

pub fn counter_type( &self, counter_id: i32, ) -> Result<AeronCounterTypeId, AeronCError>

Self::counter_type_id as an AeronCounterTypeId. Application-defined types come back as AeronCounterTypeId::Unknown

Source

pub fn counter_record_state( &self, counter_id: i32, ) -> Result<AeronCounterState, AeronCError>

Source

pub fn system_counter_value( &self, counter: AeronSystemCounterType, ) -> Result<i64, AeronCError>

The value of a media driver system counter. The driver refuses to start unless each system counter’s id equals its enum value, so no lookup is needed

Source

pub fn foreach_typed_counter_fn( &self, func: impl FnMut(i64, i32, AeronCounterTypeId, &[u8], &str), )

Self::foreach_counter_fn with the type id converted to an AeronCounterTypeId. The callback receives (value, counter_id, counter_type, key, label)

Source

pub fn get_counter_label( &self, counter_id: i32, max_length: usize, ) -> Result<String, AeronCError>

Get the label for a counter.

param counters_reader that contains the counter

param counter_id to find

param buffer to store the counter in.

param buffer_length length of the output buffer

return -1 on failure, number of characters copied to buffer on success.

Source

pub fn get_counter_label_into( &self, counter_id: i32, dst: &mut String, ) -> Result<(), AeronCError>

Get the label for a counter.

Source

pub fn get_counter_key(&self, counter_id: i32) -> Result<Vec<u8>, AeronCError>

Get all AeronCountersReader::MAX_KEY_LENGTH bytes of a counter’s key, zero padded.

This also succeeds for a freed counter. To check a counter is live, also check Self::counter_state and Self::counter_type_id.

Source

pub fn get_counter_key_into( &self, counter_id: i32, dst: &mut Vec<u8>, ) -> Result<(), AeronCError>

Replace dst with the counter’s key. See Self::get_counter_key.

Source

pub fn get_counter_key_str( &self, counter_id: i32, ) -> Result<String, AeronCError>

Get the bytes up to the first zero, or all of them if there is none. Use this for keys set from a string. Binary keys need Self::get_counter_key.

Source

pub unsafe fn counter_key_bytes( &self, counter_id: i32, ) -> Result<&[u8], AeronCError>

Borrow all AeronCountersReader::MAX_KEY_LENGTH bytes of a counter’s key without a copy.

§Safety

The slice points into driver memory. If the counter is freed while you hold it, the driver can reuse the slot and change these bytes. Only use it while the counter stays allocated. Otherwise, use Self::get_counter_key.

Source

pub fn get_counter_value(&self, counter_id: i32) -> Result<i64, AeronCError>

The current value of a counter. An error if counter_id is not a counter id, for example -1 from a lookup that found nothing

Trait Implementations§

Source§

impl<S: Clone + ResourceStorage<aeron_counters_reader_t>> Clone for AeronCountersReader<S>

Source§

fn clone(&self) -> AeronCountersReader<S>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: ResourceStorage<aeron_counters_reader_t>> Debug for AeronCountersReader<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: ResourceStorage<aeron_counters_reader_t>> From<&AeronCountersReader<S>> for *mut aeron_counters_reader_t

Source§

fn from(value: &AeronCountersReader<S>) -> Self

Converts to this type from the input type.
Source§

impl<S: ResourceStorage<aeron_counters_reader_t>> From<AeronCountersReader<S>> for *mut aeron_counters_reader_t

Source§

fn from(value: AeronCountersReader<S>) -> Self

Converts to this type from the input type.
Source§

impl<S: ResourceStorage<aeron_counters_reader_t> + SharedStorage<aeron_counters_reader_t>> Send for AeronCountersReader<S>

Source§

impl<S: ResourceStorage<aeron_counters_reader_t> + SharedStorage<aeron_counters_reader_t>> Sync for AeronCountersReader<S>

Auto Trait Implementations§

§

impl<S> Freeze for AeronCountersReader<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for AeronCountersReader<S>
where S: RefUnwindSafe,

§

impl<S> Unpin for AeronCountersReader<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for AeronCountersReader<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for AeronCountersReader<S>
where S: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.