pub struct Handler<T> { /* private fields */ }Expand description
A reference-counted callback that C stores and calls later.
Clones share one heap allocation. C uses the pointer from Handler::as_raw,
so the callback must stay alive until C stops using it. Dropping a Handler
does not unregister it, and the callback is freed when its last clone drops.
Owned resources retain handler clones until their last owner drops and C cleanup
finishes. The client also retains publication, subscription and counter handlers,
because the conductor can call them after close() returns. An archive connection
copies handler pointers when it starts, so replacing a handler on the original
context neither updates that copy nor frees the old handler. Borrowed wrappers
retain nothing, so keep your Handler alive while C can call it.
Earlier manual cleanup often freed handlers while C could still call them,
causing crashes or memory corruption. Keeping them through cleanup avoids this
mistake, but keeps replaced closures and their captured values in memory too.
Earlier release needs to track every C user through connection setup and cleanup.
An Arc alone cannot track C’s raw pointer copies.
To replace callbacks often, register an AeronErrorHandlerSlot once.
Use set or clear to free old callbacks after their last call.
Use *_fn or *_once for callbacks that run during the call. Their closures
stay on the stack, can borrow local variables and need no heap allocation.
Handler<T> is Send when T is Send. It is also Sync when T is Send
and the multi-threaded feature is enabled.
use rusteron_code_gen::Handler;
let handler = Handler::new(your_value);
// The callback is freed when its last Handler clone drops.Implementations§
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>
use Handler::with_fragment_assembler
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>
use Handler::with_controlled_fragment_assembler
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.