pub struct Handler<T> { /* private fields */ }Expand description
§Handler
Heap-allocated, reference-counted callback holder for callbacks the C client retains (fires later, possibly many times, from the conductor thread).
Handler<T> wraps Arc<UnsafeCell<T>>. The callback value lives on the heap
and is freed only when the last clone drops. The raw clientd pointer handed
to C is &T (via Handler::as_raw); C keeps firing it for as long as it
holds the callback, so the Handler must outlive that — methods that register
a retained callback (AeronContext::set_error_handler, the image lifecycle
handlers on async_add_subscription, set_on_available_image, …) store a
clone of the Handler inside the registering resource (as a dependency), so
the value is guaranteed to outlive the C side’s use of it. No manual
release() is needed.
§Heap vs stack — when to reach for Handler vs a *_fn / *_once method
| Callback kind | Where the closure lives | API |
|---|---|---|
| Retained (C stores it; fires later / repeatedly) | heap (Handler/Arc) | set_error_handler(Some(Handler::new(...))), async_add_subscription(.., Some(&h), ..), poll(Some(&h), limit) |
| Sync / call-only (C fires it during the call, then is done) | stack (borrowed FnMut, zero allocation) | poll_fn(|msg, hdr| ..., limit), the generated *_once variants |
Prefer the stack form (poll_fn, *_once) on the hot path: it borrows the
closure for the duration of the call only, so there is no Arc, no heap
allocation, and the closure may borrow local state. Reach for Handler
(heap) when the callback must survive past the registering call — image
lifecycle handlers, error handlers, counters callbacks, anything the
conductor invokes asynchronously.
The reference count is atomic (Arc), so a Handler may be moved to another
thread; it is deliberately not Sync — callbacks fire from the conductor
thread and must not be shared concurrently.
§Example
use rusteron_code_gen::Handler;
let handler = Handler::new(your_value);
// the value is freed when the last clone of `handler` goes out of scopeImplementations§
Source§impl<T: AeronFragmentHandlerCallback + 'static> Handler<T>
impl<T: AeronFragmentHandlerCallback + 'static> Handler<T>
Sourcepub fn with_fragment_assembler(
handler: T,
) -> Result<(Handler<AeronFragmentAssembler>, Handler<T>), AeronCError>
pub fn with_fragment_assembler( handler: T, ) -> Result<(Handler<AeronFragmentAssembler>, Handler<T>), AeronCError>
Wrap handler in a fragment assembler; both are reference-counted and freed
automatically when the last clones drop (the assembler keeps the delegate alive).
pub fn leak_with_fragment_assembler( handler: T, ) -> Result<(Handler<AeronFragmentAssembler>, Handler<T>), AeronCError>
Source§impl<T: AeronControlledFragmentHandlerCallback + 'static> Handler<T>
impl<T: AeronControlledFragmentHandlerCallback + 'static> Handler<T>
Sourcepub fn with_controlled_fragment_assembler(
handler: T,
) -> Result<(Handler<AeronControlledFragmentAssembler>, Handler<T>), AeronCError>
pub fn with_controlled_fragment_assembler( handler: T, ) -> Result<(Handler<AeronControlledFragmentAssembler>, Handler<T>), AeronCError>
Wrap handler in a controlled fragment assembler; both are reference-counted and
freed automatically when the last clones drop.
pub fn leak_with_controlled_fragment_assembler( handler: T, ) -> Result<(Handler<AeronControlledFragmentAssembler>, Handler<T>), AeronCError>
Trait Implementations§
Source§impl<T: AeronAgentCloseFuncCallback> AeronAgentCloseFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronAgentCloseFuncCallback> AeronAgentCloseFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_agent_on_close_func(&mut self)
Source§impl<T: AeronAgentDoWorkFuncCallback> AeronAgentDoWorkFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronAgentDoWorkFuncCallback> AeronAgentDoWorkFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_agent_do_work_func(&mut self) -> c_int
Source§impl<T: AeronAgentStartFuncCallback> AeronAgentStartFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronAgentStartFuncCallback> AeronAgentStartFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_agent_on_start_func(&mut self, role_name: &str)
Source§impl<T: AeronArchiveCredentialsChallengeSupplierFuncCallback> AeronArchiveCredentialsChallengeSupplierFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronArchiveCredentialsChallengeSupplierFuncCallback> AeronArchiveCredentialsChallengeSupplierFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_archive_credentials_challenge_supplier_func( &mut self, encoded_challenge: AeronArchiveEncodedCredentials, ) -> *mut aeron_archive_encoded_credentials_t
Source§impl<T: AeronArchiveCredentialsEncodedCredentialsSupplierFuncCallback> AeronArchiveCredentialsEncodedCredentialsSupplierFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronArchiveCredentialsEncodedCredentialsSupplierFuncCallback> AeronArchiveCredentialsEncodedCredentialsSupplierFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
Source§impl<T: AeronArchiveCredentialsFreeFuncCallback> AeronArchiveCredentialsFreeFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronArchiveCredentialsFreeFuncCallback> AeronArchiveCredentialsFreeFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_archive_credentials_free_func( &mut self, credentials: AeronArchiveEncodedCredentials, )
Source§impl<T: AeronArchiveDelegatingInvokerFuncCallback> AeronArchiveDelegatingInvokerFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronArchiveDelegatingInvokerFuncCallback> AeronArchiveDelegatingInvokerFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_archive_delegating_invoker_func(&mut self)
Source§impl<T: AeronArchiveRecordingDescriptorConsumerFuncCallback> AeronArchiveRecordingDescriptorConsumerFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronArchiveRecordingDescriptorConsumerFuncCallback> AeronArchiveRecordingDescriptorConsumerFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_archive_recording_descriptor_consumer_func( &mut self, recording_descriptor: AeronArchiveRecordingDescriptor, )
Source§impl<T: AeronArchiveRecordingSignalConsumerFuncCallback> AeronArchiveRecordingSignalConsumerFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronArchiveRecordingSignalConsumerFuncCallback> AeronArchiveRecordingSignalConsumerFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_archive_recording_signal_consumer_func( &mut self, recording_signal: AeronArchiveRecordingSignal, )
Source§impl<T: AeronArchiveRecordingSubscriptionDescriptorConsumerFuncCallback> AeronArchiveRecordingSubscriptionDescriptorConsumerFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronArchiveRecordingSubscriptionDescriptorConsumerFuncCallback> AeronArchiveRecordingSubscriptionDescriptorConsumerFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_archive_recording_subscription_descriptor_consumer_func( &mut self, recording_subscription_descriptor: AeronArchiveRecordingSubscriptionDescriptor, )
Source§impl<T: AeronAvailableCounterCallback> AeronAvailableCounterCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronAvailableCounterCallback> AeronAvailableCounterCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_on_available_counter( &mut self, counters_reader: AeronCountersReader, registration_id: i64, counter_id: i32, )
Source§impl<T: AeronAvailableImageCallback> AeronAvailableImageCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronAvailableImageCallback> AeronAvailableImageCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_on_available_image( &mut self, subscription: AeronSubscription, image: AeronImage, )
Source§impl<T: AeronBlockHandlerCallback> AeronBlockHandlerCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronBlockHandlerCallback> AeronBlockHandlerCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
Source§impl<T: AeronCloseClientCallback> AeronCloseClientCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronCloseClientCallback> AeronCloseClientCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_on_close_client(&mut self)
Source§impl<T: AeronControlledFragmentHandlerCallback> AeronControlledFragmentHandlerCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronControlledFragmentHandlerCallback> AeronControlledFragmentHandlerCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_controlled_fragment_handler( &mut self, buffer: &[u8], header: AeronHeader, ) -> aeron_controlled_fragment_handler_action_t
Source§impl<T: AeronCountersReaderForeachCounterFuncCallback> AeronCountersReaderForeachCounterFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronCountersReaderForeachCounterFuncCallback> AeronCountersReaderForeachCounterFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
Source§impl<T: AeronErrorHandlerCallback> AeronErrorHandlerCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronErrorHandlerCallback> AeronErrorHandlerCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_error_handler(&mut self, errcode: c_int, message: &str)
Source§impl<T: AeronErrorLogReaderFuncCallback> AeronErrorLogReaderFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronErrorLogReaderFuncCallback> AeronErrorLogReaderFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
Source§impl<T: AeronFprintfHandlerCallback> AeronFprintfHandlerCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronFprintfHandlerCallback> AeronFprintfHandlerCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
Source§impl<T: AeronFragmentHandlerCallback> AeronFragmentHandlerCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronFragmentHandlerCallback> AeronFragmentHandlerCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_fragment_handler(&mut self, buffer: &[u8], header: AeronHeader)
Source§impl<T: AeronIdleStrategyFuncCallback> AeronIdleStrategyFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronIdleStrategyFuncCallback> AeronIdleStrategyFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_idle_strategy_func(&mut self, work_count: c_int)
Source§impl<T: AeronLossReporterReadEntryFuncCallback> AeronLossReporterReadEntryFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronLossReporterReadEntryFuncCallback> AeronLossReporterReadEntryFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
Source§impl<T: AeronNewPublicationCallback> AeronNewPublicationCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronNewPublicationCallback> AeronNewPublicationCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
Source§impl<T: AeronNewSubscriptionCallback> AeronNewSubscriptionCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronNewSubscriptionCallback> AeronNewSubscriptionCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
Source§impl<T: AeronNotificationCallback> AeronNotificationCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronNotificationCallback> AeronNotificationCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_notification(&mut self)
Source§impl<T: AeronPublicationErrorFrameHandlerCallback> AeronPublicationErrorFrameHandlerCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronPublicationErrorFrameHandlerCallback> AeronPublicationErrorFrameHandlerCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_publication_error_frame_handler( &mut self, error_frame: AeronPublicationErrorValues, )
Source§impl<T: AeronReservedValueSupplierCallback> AeronReservedValueSupplierCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronReservedValueSupplierCallback> AeronReservedValueSupplierCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
fn handle_aeron_reserved_value_supplier(&mut self, buffer: &mut [u8]) -> i64
Source§impl<T: AeronStrToPtrHashMapForEachFuncCallback> AeronStrToPtrHashMapForEachFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronStrToPtrHashMapForEachFuncCallback> AeronStrToPtrHashMapForEachFuncCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
Source§impl<T: AeronUriParseCallbackCallback> AeronUriParseCallbackCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.
impl<T: AeronUriParseCallbackCallback> AeronUriParseCallbackCallback for Handler<T>
Pass an existing Handler clone anywhere a callback value is expected, e.g.
to share one callback instance across several registrations.