pub struct AeronSubscription<S: ResourceStorage<aeron_subscription_t> = LiveCResource<aeron_subscription_t>> { /* private fields */ }Implementations§
Source§impl<S: ResourceStorage<aeron_subscription_t>> AeronSubscription<S>
impl<S: ResourceStorage<aeron_subscription_t>> AeronSubscription<S>
Sourcepub fn poll<AeronFragmentHandlerHandlerImpl: AeronFragmentHandlerCallback>(
&self,
handler: &mut AeronFragmentHandlerHandlerImpl,
fragment_limit: usize,
) -> Result<i32, AeronCError>
pub fn poll<AeronFragmentHandlerHandlerImpl: AeronFragmentHandlerCallback>( &self, handler: &mut AeronFragmentHandlerHandlerImpl, fragment_limit: usize, ) -> Result<i32, AeronCError>
Poll the images under the subscription for available message fragments.
Each fragment read will be a whole message if it is under MTU length. If larger than MTU then it will come as a series of fragments ordered within a session.
To assemble messages that span multiple fragments then use FragmentAssembler.
§Parameters
handlerfor handling each message fragment as it is read.fragment_limitnumber of message fragments to limit when polling across multiple images.
§Return
the number of fragments received or -1 for error.
Borrows the callback exclusively until this call returns. This method uses no callback allocation, reference count, runtime borrow check or mutex. The callback can borrow local state.
Sourcepub fn poll_fn<AeronFragmentHandlerHandlerImpl: FnMut(&[u8], &AeronHeader<Borrowed<aeron_header_t>>)>(
&self,
handler: AeronFragmentHandlerHandlerImpl,
fragment_limit: usize,
) -> Result<i32, AeronCError>
pub fn poll_fn<AeronFragmentHandlerHandlerImpl: FnMut(&[u8], &AeronHeader<Borrowed<aeron_header_t>>)>( &self, handler: AeronFragmentHandlerHandlerImpl, fragment_limit: usize, ) -> Result<i32, AeronCError>
Poll the images under the subscription for available message fragments.
Each fragment read will be a whole message if it is under MTU length. If larger than MTU then it will come as a series of fragments ordered within a session.
To assemble messages that span multiple fragments then use FragmentAssembler.
§Parameters
handlerfor handling each message fragment as it is read.fragment_limitnumber of message fragments to limit when polling across multiple images.
§Return
the number of fragments received or -1 for error.
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 passed to the caller. Fragments since the poll
started (or the last COMMIT) are delivered again on the next poll
Sourcepub fn controlled_poll<AeronControlledFragmentHandlerHandlerImpl: AeronControlledFragmentHandlerCallback>(
&self,
handler: &mut AeronControlledFragmentHandlerHandlerImpl,
fragment_limit: usize,
) -> Result<i32, AeronCError>
pub fn controlled_poll<AeronControlledFragmentHandlerHandlerImpl: AeronControlledFragmentHandlerCallback>( &self, handler: &mut AeronControlledFragmentHandlerHandlerImpl, fragment_limit: usize, ) -> Result<i32, AeronCError>
Poll in a controlled manner the images under the subscription for available message fragments. Control is applied to fragments in the stream. If more fragments can be read on another stream they will even if BREAK or ABORT is returned from the fragment handler.
Each fragment read will be a whole message if it is under MTU length. If larger than MTU then it will come as a series of fragments ordered within a session.
To assemble messages that span multiple fragments then use ControlledFragmentAssembler.
§Parameters
handlerfor handling each message fragment as it is read.fragment_limitnumber of message fragments to limit when polling across multiple images.
§Return
the number of fragments received or -1 for error.
Borrows the callback exclusively until this call returns. This method uses no callback allocation, reference count, runtime borrow check or mutex. The callback can borrow local state.
Sourcepub fn controlled_poll_fn<AeronControlledFragmentHandlerHandlerImpl: FnMut(&[u8], &AeronHeader<Borrowed<aeron_header_t>>) -> aeron_controlled_fragment_handler_action_t>(
&self,
handler: AeronControlledFragmentHandlerHandlerImpl,
fragment_limit: usize,
) -> Result<i32, AeronCError>
pub fn controlled_poll_fn<AeronControlledFragmentHandlerHandlerImpl: FnMut(&[u8], &AeronHeader<Borrowed<aeron_header_t>>) -> aeron_controlled_fragment_handler_action_t>( &self, handler: AeronControlledFragmentHandlerHandlerImpl, fragment_limit: usize, ) -> Result<i32, AeronCError>
Poll in a controlled manner the images under the subscription for available message fragments. Control is applied to fragments in the stream. If more fragments can be read on another stream they will even if BREAK or ABORT is returned from the fragment handler.
Each fragment read will be a whole message if it is under MTU length. If larger than MTU then it will come as a series of fragments ordered within a session.
To assemble messages that span multiple fragments then use ControlledFragmentAssembler.
§Parameters
handlerfor handling each message fragment as it is read.fragment_limitnumber of message fragments to limit when polling across multiple images.
§Return
the number of fragments received or -1 for error.
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 passed to the caller. Fragments since the poll
started (or the last COMMIT) are delivered again on the next poll
Sourcepub fn block_poll<AeronBlockHandlerHandlerImpl: AeronBlockHandlerCallback>(
&self,
handler: &mut AeronBlockHandlerHandlerImpl,
block_length_limit: usize,
) -> c_long
pub fn block_poll<AeronBlockHandlerHandlerImpl: AeronBlockHandlerCallback>( &self, handler: &mut AeronBlockHandlerHandlerImpl, block_length_limit: usize, ) -> c_long
Poll the images under the subscription for available message fragments in blocks.
This method is useful for operations like bulk archiving and messaging indexing.
§Parameters
handlerto receive a block of fragments from each image.block_length_limitfor each image polled.
§Return
the number of bytes consumed or -1 for error.
Borrows the callback exclusively until this call returns. This method uses no callback allocation, reference count, runtime borrow check or mutex. The callback can borrow local state.
Sourcepub fn block_poll_fn<AeronBlockHandlerHandlerImpl: FnMut(&[u8], i32, i32)>(
&self,
handler: AeronBlockHandlerHandlerImpl,
block_length_limit: usize,
) -> c_long
pub fn block_poll_fn<AeronBlockHandlerHandlerImpl: FnMut(&[u8], i32, i32)>( &self, handler: AeronBlockHandlerHandlerImpl, block_length_limit: usize, ) -> c_long
Poll the images under the subscription for available message fragments in blocks.
This method is useful for operations like bulk archiving and messaging indexing.
§Parameters
handlerto receive a block of fragments from each image.block_length_limitfor each image polled.
§Return
the number of bytes consumed or -1 for error.
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 passed to the caller. Fragments since the poll
started (or the last COMMIT) are delivered again on the next poll
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Is this subscription connected by having at least one open publication image.
§Return
true if this subscription connected by having at least one open publication image.
Sourcepub unsafe fn constants(
&self,
constants: &AeronSubscriptionConstants<impl ResourceStorage<aeron_subscription_constants_t>>,
) -> Result<i32, AeronCError>
pub unsafe fn constants( &self, constants: &AeronSubscriptionConstants<impl ResourceStorage<aeron_subscription_constants_t>>, ) -> Result<i32, AeronCError>
Fill in a structure with the constants in use by a subscription.
§Parameters
constantsstructure to fill in with the constants
§Return
0 for success and -1 for error.
§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.
Sourcepub fn get_constants(
&self,
) -> Result<AeronSubscriptionConstants<ScopedInline<'_, aeron_subscription_constants_t>>, AeronCError>
pub fn get_constants( &self, ) -> Result<AeronSubscriptionConstants<ScopedInline<'_, aeron_subscription_constants_t>>, AeronCError>
Fill in a structure with the constants in use by a subscription.
Sourcepub fn channel_status_indicator_id(&self) -> Result<i32, AeronCError>
pub fn channel_status_indicator_id(&self) -> Result<i32, AeronCError>
get_constants()?.channel_status_indicator_id(). Call get_constants() once to read several fields
Sourcepub fn image_count(&self) -> Result<i32, AeronCError>
pub fn image_count(&self) -> Result<i32, AeronCError>
Count of images associated to this subscription.
§Return
count of count associated to this subscription or -1 for error.
Sourcepub unsafe fn image_retain(
&self,
image: &AeronImage<impl ResourceStorage<aeron_image_t>>,
) -> Result<i32, AeronCError>
pub unsafe fn image_retain( &self, image: &AeronImage<impl ResourceStorage<aeron_image_t>>, ) -> Result<i32, AeronCError>
Retain the given image for access in the application.
Note: A retain call must have a corresponding release call. Note: Subscriptions are not threadsafe and should not be shared between subscribers.
§Parameters
imageto retain
§Return
0 for success and -1 for error.
§Safety
This bypasses Rust ownership. Keep all retained pointers valid until native cleanup. Initializers require exclusive access and must not overwrite live native state or invalidate borrowed views. After raw removal or deletion, prevent all further access and Rust cleanup through every alias. Prefer the owning handle’s constructor, close or cancel method.
Sourcepub unsafe fn image_release(
&self,
image: &AeronImage<impl ResourceStorage<aeron_image_t>>,
) -> Result<i32, AeronCError>
pub unsafe fn image_release( &self, image: &AeronImage<impl ResourceStorage<aeron_image_t>>, ) -> Result<i32, AeronCError>
Release the given image and relinquish desire to use the image directly.
Note: Subscriptions are not threadsafe and should not be shared between subscribers.
§Parameters
imageto release
§Return
0 for success and -1 for error.
§Safety
This bypasses Rust ownership. Keep all retained pointers valid until native cleanup. Initializers require exclusive access and must not overwrite live native state or invalidate borrowed views. After raw removal or deletion, prevent all further access and Rust cleanup through every alias. Prefer the owning handle’s constructor, close or cancel method.
Sourcepub fn channel_status(&self) -> i64
pub fn channel_status(&self) -> i64
Get the status of the media channel for this subscription.
The status will be ERRORED (-1) if a socket exception occurs on setup and ACTIVE (1) if all is well.
§Return
1 for ACTIVE, -1 for ERRORED
Sourcepub fn local_sockaddrs(
&self,
address_vec: &AeronIovec,
address_vec_len: usize,
) -> Result<i32, AeronCError>
pub fn local_sockaddrs( &self, address_vec: &AeronIovec, address_vec_len: usize, ) -> Result<i32, AeronCError>
Get all of the local socket addresses for this subscription. Multiple addresses can occur if this is a
multi-destination subscription. Addresses will a string representation in numeric form. IPv6 addresses will be
surrounded by ‘[’ and ‘]’ so that the ‘:’ that separate the parts are distinguishable from the port delimiter.
E.g. [fe80::7552:c06e:6bf4:4160]:12345. As of writing the maximum length for a formatted address is 54 bytes
including the NULL terminator. AERON_CLIENT_MAX_LOCAL_ADDRESS_STR_LEN is defined to provide enough space to fit the
returned string. Returned strings will be NULL terminated. If the buffer to hold the address can not hold enough
of the message it will be truncated and the last character will be null.
If the address_vec_len is less the total number of addresses available then the first addresses found up to that length will be placed into the address_vec. However the function will return the total number of addresses available so if if that is larger than the input array then the client code may wish to re-query with a larger array to get them all.
§Parameters
address_vecto hold the received addressesaddress_vec_lenavailable length of the vector to hold the addresses
§Return
number of addresses found or -1 if there is an error.
Sourcepub fn resolved_endpoint(&self, address: &mut [u8]) -> Result<i32, AeronCError>
pub fn resolved_endpoint(&self, address: &mut [u8]) -> Result<i32, AeronCError>
Retrieves the first local socket address for this subscription. If this is not MDS then it will be the one representing endpoint for this subscription.
§Parameters
addressbuffer to hold the resolved endooint.
§Return
-1 on error, 0 if address not found, 1 if address is found. @see aeron_subscription_local_sockaddrs
Sourcepub fn resolved_endpoint_as_string(
&self,
max_length: usize,
) -> Result<String, AeronCError>
pub fn resolved_endpoint_as_string( &self, max_length: usize, ) -> Result<String, AeronCError>
Retrieves the first local socket address for this subscription. If this is not MDS then it will be the one representing endpoint for this subscription.
§Parameters
addressbuffer to hold the resolved endooint.
§Return
-1 on error, 0 if address not found, 1 if address is found. @see aeron_subscription_local_sockaddrs
Sourcepub fn resolved_endpoint_into(
&self,
dst_truncate_to_capacity: &mut String,
) -> Result<i32, AeronCError>
pub fn resolved_endpoint_into( &self, dst_truncate_to_capacity: &mut String, ) -> Result<i32, AeronCError>
Retrieves the first local socket address for this subscription. If this is not MDS then it will be the one representing endpoint for this subscription.
§Parameters
addressbuffer to hold the resolved endooint.
§Return
-1 on error, 0 if address not found, 1 if address is found. @see aeron_subscription_local_sockaddrs NOTE: allocation friendly method, the string capacity must be set as it will truncate string to capacity it will never grow the string. So if you pass String::new() it will write 0 chars
Sourcepub fn try_resolve_channel_endpoint_port(
&self,
uri: &mut [u8],
) -> Result<i32, AeronCError>
pub fn try_resolve_channel_endpoint_port( &self, uri: &mut [u8], ) -> Result<i32, AeronCError>
Retrieves the channel URI for this subscription with any wildcard ports filled in. If the channel is not UDP or
does not have a wildcard port (0), then it will return the original URI.
§Parameters
uribuffer to hold the resolved uri.
§Return
-1 on failure or the number of bytes written to the buffer (excluding the NULL terminator). Writing is done on a per key basis, so if the buffer was truncated before writing completed, it will only include the byte count up to the key that overflowed. However, the invariant that if the number returned >= uri_len, then output will have been truncated.
Sourcepub fn try_resolve_channel_endpoint_port_as_string(
&self,
max_length: usize,
) -> Result<String, AeronCError>
pub fn try_resolve_channel_endpoint_port_as_string( &self, max_length: usize, ) -> Result<String, AeronCError>
Retrieves the channel URI for this subscription with any wildcard ports filled in. If the channel is not UDP or
does not have a wildcard port (0), then it will return the original URI.
§Parameters
uribuffer to hold the resolved uri.
§Return
-1 on failure or the number of bytes written to the buffer (excluding the NULL terminator). Writing is done on a per key basis, so if the buffer was truncated before writing completed, it will only include the byte count up to the key that overflowed. However, the invariant that if the number returned >= uri_len, then output will have been truncated.
Sourcepub fn try_resolve_channel_endpoint_port_into(
&self,
dst_truncate_to_capacity: &mut String,
) -> Result<i32, AeronCError>
pub fn try_resolve_channel_endpoint_port_into( &self, dst_truncate_to_capacity: &mut String, ) -> Result<i32, AeronCError>
Retrieves the channel URI for this subscription with any wildcard ports filled in. If the channel is not UDP or
does not have a wildcard port (0), then it will return the original URI.
§Parameters
uribuffer to hold the resolved uri.
§Return
-1 on failure or the number of bytes written to the buffer (excluding the NULL terminator). Writing is done on a per key basis, so if the buffer was truncated before writing completed, it will only include the byte count up to the key that overflowed. However, the invariant that if the number returned >= uri_len, then output will have been truncated. NOTE: allocation friendly method, the string capacity must be set as it will truncate string to capacity it will never grow the string. So if you pass String::new() it will write 0 chars
pub fn get_inner(&self) -> *mut aeron_subscription_t
Sourcepub unsafe fn get_inner_mut(&self) -> &mut aeron_subscription_t
pub unsafe fn get_inner_mut(&self) -> &mut aeron_subscription_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.
Sourcepub unsafe fn get_inner_ref(&self) -> &aeron_subscription_t
pub unsafe fn get_inner_ref(&self) -> &aeron_subscription_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 AeronSubscription
impl AeronSubscription
Sourcepub unsafe fn from_ptr(
ptr: *mut aeron_subscription_t,
) -> AeronSubscription<Borrowed<aeron_subscription_t>>
pub unsafe fn from_ptr( ptr: *mut aeron_subscription_t, ) -> AeronSubscription<Borrowed<aeron_subscription_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 AeronSubscription
impl AeronSubscription
Sourcepub fn close(self) -> Result<(), AeronCError>
pub fn close(self) -> Result<(), AeronCError>
Releases this handle. Native cleanup waits for the last owning clone when the resource can be retained by another handle.
Source§impl AeronSubscription
impl AeronSubscription
Sourcepub fn close_with_handler<AeronNotificationHandlerImpl: AeronNotificationCallback + Send + 'static>(
self,
on_close_complete: Option<&SharedHandler<AeronNotificationHandlerImpl>>,
) -> Result<(), AeronCError>
pub fn close_with_handler<AeronNotificationHandlerImpl: AeronNotificationCallback + Send + 'static>( self, on_close_complete: Option<&SharedHandler<AeronNotificationHandlerImpl>>, ) -> Result<(), AeronCError>
Like Self::close, but calls on_close_complete from the conductor once
the close finishes. Returns an error unless this is the last owning handle.
The client keeps the SharedHandler alive until it has fired
Source§impl AeronSubscription
impl AeronSubscription
Sourcepub fn async_add_destination(
&self,
client: &Aeron,
uri: &CStr,
) -> Result<AeronAsyncDestination, AeronCError>
pub fn async_add_destination( &self, client: &Aeron, uri: &CStr, ) -> Result<AeronAsyncDestination, AeronCError>
Start a destination change. Dropping the operation does not cancel it.
Sourcepub fn add_destination(
&self,
uri: &CStr,
timeout: Duration,
) -> Result<(), AeronCError>
pub fn add_destination( &self, uri: &CStr, timeout: Duration, ) -> Result<(), AeronCError>
Wait for a destination change or the timeout. Drives an invoker conductor when needed. The handle retains its owning client. A timeout does not cancel the native operation.
Sourcepub fn async_remove_destination(
&self,
client: &Aeron,
uri: &CStr,
) -> Result<AeronAsyncDestination, AeronCError>
pub fn async_remove_destination( &self, client: &Aeron, uri: &CStr, ) -> Result<AeronAsyncDestination, AeronCError>
Start a destination change. Dropping the operation does not cancel it.
Sourcepub fn remove_destination(
&self,
uri: &CStr,
timeout: Duration,
) -> Result<(), AeronCError>
pub fn remove_destination( &self, uri: &CStr, timeout: Duration, ) -> Result<(), AeronCError>
Wait for a destination change or the timeout. Drives an invoker conductor when needed. The handle retains its owning client. A timeout does not cancel the native operation.
Source§impl AeronSubscription
impl AeronSubscription
Sourcepub fn image_at_index(&self, index: usize) -> Option<AeronImage>
pub fn image_at_index(&self, index: usize) -> Option<AeronImage>
A retained image handle for index, or None when no such image exists.
The returned AeronImage releases the image when it drops. Until then the image
stays valid even once it becomes unavailable: AeronImage::is_closed turns true,
polling reads nothing more, and its log buffer stays mapped. The image keeps the
native subscription open, so Self::close waits for the image to drop
Each call returns a new handle, and every handle to the same image shares one position with the subscription, which the borrow checker cannot see. Do not poll one handle inside a poll of another handle to the same image or of its subscription, and do not keep polling it on this thread after the subscription moves to another thread. Either one races on the image position and can deliver fragments twice. Aeron Java and C++ do not check for this either
The image is one publisher session: a publisher that reconnects with a new session
is a new image, so poll the subscription, or fetch the new image, to follow it. To
keep an image passed to an image callback, whose arguments are valid only during the
call, retain it here (or with Self::image_by_session_id) on your own subscription.
Sourcepub fn image_by_session_id(&self, session_id: i32) -> Option<AeronImage>
pub fn image_by_session_id(&self, session_id: i32) -> Option<AeronImage>
A retained image handle for session_id, or None when no such image exists.
Same automatic-release semantics as Self::image_at_index.
Sourcepub fn for_each_image<F: FnMut(&AeronImageRef)>(&self, f: F)
pub fn for_each_image<F: FnMut(&AeronImageRef)>(&self, f: F)
Borrow-scoped iteration over the current images, with zero retain/release bookkeeping.
The borrowed AeronImage is only valid inside the closure; call
Self::image_at_index / Self::image_by_session_id for a handle that outlives it.
Source§impl<S: ResourceStorage<aeron_subscription_t>> AeronSubscription<S>
impl<S: ResourceStorage<aeron_subscription_t>> AeronSubscription<S>
Sourcepub fn status(&self) -> AeronStatus
pub fn status(&self) -> AeronStatus
High-level connection state derived from the subscription handle.
Sourcepub fn stream_id(&self) -> Result<i32, AeronCError>
pub fn stream_id(&self) -> Result<i32, AeronCError>
Accessor for the stream id (no direct C accessor exists for
subscriptions; backed by Self::get_constants). For a hot loop, call
Self::get_constants once and reuse the returned
AeronSubscriptionConstants.
Sourcepub fn channel(&self) -> Result<String, AeronCError>
pub fn channel(&self) -> Result<String, AeronCError>
Accessor for the channel (see Self::stream_id).
Sourcepub fn registration_id(&self) -> Result<i64, AeronCError>
pub fn registration_id(&self) -> Result<i64, AeronCError>
Accessor for the registration id (see Self::stream_id).