pub struct AeronPublication { /* private fields */ }Implementations§
Source§impl AeronPublication
impl AeronPublication
pub fn new(async_: &AeronAsyncAddPublication) -> Result<Self, AeronCError>
Source§impl AeronPublication
impl AeronPublication
Sourcepub fn new_zeroed_on_heap() -> Self
pub fn new_zeroed_on_heap() -> Self
creates zeroed struct where the underlying c struct is on the heap
Sourcepub fn new_zeroed_on_stack() -> Self
pub fn new_zeroed_on_stack() -> Self
creates zeroed struct where the underlying c struct is on the stack (Use with care)
Sourcepub fn offerv<AeronReservedValueSupplierHandlerImpl: AeronReservedValueSupplierCallback>(
&self,
iov: &AeronIovec,
iovcnt: usize,
reserved_value_supplier: Option<&Handler<AeronReservedValueSupplierHandlerImpl>>,
) -> i64
pub fn offerv<AeronReservedValueSupplierHandlerImpl: AeronReservedValueSupplierCallback>( &self, iov: &AeronIovec, iovcnt: usize, reserved_value_supplier: Option<&Handler<AeronReservedValueSupplierHandlerImpl>>, ) -> i64
Non-blocking publish by gathering buffer vectors into a message.
§Parameters
iovarray for the vectorsiovcntof the number of vectorsreserved_value_supplierto use for setting the reserved value field or NULL.clientdto pass to the reserved_value_supplier.
§Return
the new stream position otherwise a negative error value.
Sourcepub fn offerv_fn<AeronReservedValueSupplierHandlerImpl: FnMut(&mut [u8]) -> i64>(
&self,
iov: &AeronIovec,
iovcnt: usize,
reserved_value_supplier: AeronReservedValueSupplierHandlerImpl,
) -> i64
pub fn offerv_fn<AeronReservedValueSupplierHandlerImpl: FnMut(&mut [u8]) -> i64>( &self, iov: &AeronIovec, iovcnt: usize, reserved_value_supplier: AeronReservedValueSupplierHandlerImpl, ) -> i64
Non-blocking publish by gathering buffer vectors into a message.
§Parameters
iovarray for the vectorsiovcntof the number of vectorsreserved_value_supplierto use for setting the reserved value field or NULL.clientdto pass to the reserved_value_supplier.
§Return
the new stream position otherwise a negative error value.
Stack-borrowed closure (_fn variant): the FnMut closure lives on the
caller’s stack and is borrowed for this call only. The callback fires
synchronously inside the call, so nothing is heap-allocated, nothing is stored,
and the closure may borrow local state. Prefer this over the retained
Handler-based form on the hot path; only generated for callbacks the C
client does not retain (i.e. not stored for later firing).
§Panics
A panic in the closure is caught so the C call can finish, then passed to the caller once it returns
Sourcepub fn channel_status(&self) -> i64
pub fn channel_status(&self) -> i64
Get the status of the media channel for this publication.
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 is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Has the publication seen an active Subscriber recently?
§Return
true if this publication has recently seen an active subscriber otherwise false.
Sourcepub fn constants(
&self,
constants: &AeronPublicationConstants,
) -> Result<i32, AeronCError>
pub fn constants( &self, constants: &AeronPublicationConstants, ) -> Result<i32, AeronCError>
Sourcepub fn get_constants(&self) -> Result<AeronPublicationConstants, AeronCError>
pub fn get_constants(&self) -> Result<AeronPublicationConstants, AeronCError>
Fill in a structure with the constants in use by a publication.
Sourcepub fn position(&self) -> i64
pub fn position(&self) -> i64
Get the current position to which the publication has advanced for this stream.
§Return
the current position to which the publication has advanced for this stream or a negative error value.
Sourcepub fn position_limit(&self) -> i64
pub fn position_limit(&self) -> i64
Get the position limit beyond which this publication will be back pressured.
This should only be used as a guide to determine when back pressure is likely to be applied.
§Return
the position limit beyond which this publication will be back pressured or a negative error value.
Sourcepub fn session_id(&self) -> i32
pub fn session_id(&self) -> i32
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 publication. Typically only one representing the control address.
§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.
@see aeron_subscription_local_Sockaddrs
pub fn get_inner(&self) -> *mut aeron_publication_t
Sourcepub unsafe fn get_inner_mut(&self) -> &mut aeron_publication_t
pub unsafe fn get_inner_mut(&self) -> &mut aeron_publication_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.
pub fn get_inner_ref(&self) -> &aeron_publication_t
Source§impl AeronPublication
impl AeronPublication
Sourcepub fn close(self) -> Result<(), AeronCError>
pub fn close(self) -> Result<(), AeronCError>
Closes this resource in the C client immediately; all clones of this handle become closed (their pointer is nulled) and must not be used.
Source§impl AeronPublication
impl AeronPublication
Sourcepub fn close_with_handler<AeronNotificationHandlerImpl: AeronNotificationCallback>(
self,
on_close_complete: Option<&Handler<AeronNotificationHandlerImpl>>,
) -> Result<(), AeronCError>
pub fn close_with_handler<AeronNotificationHandlerImpl: AeronNotificationCallback>( self, on_close_complete: Option<&Handler<AeronNotificationHandlerImpl>>, ) -> Result<(), AeronCError>
Like Self::close, but notifies on_close_complete when the close
finishes. The handler must outlive the notification (keep your
Handler alive until it has fired).
Source§impl AeronPublication
impl AeronPublication
pub fn async_add_destination( &self, client: &Aeron, destination: &CStr, ) -> Result<AeronAsyncDestination, AeronCError>
Sourcepub fn add_destination(
&self,
destination: &CStr,
timeout: Duration,
) -> Result<(), AeronCError>
pub fn add_destination( &self, destination: &CStr, timeout: Duration, ) -> Result<(), AeronCError>
Add destination (see AeronSubscription::add_destination); the owning
Aeron client is retrieved from the publication’s dependency graph.
Sourcepub fn async_remove_destination(
&self,
client: &Aeron,
destination: &CStr,
) -> Result<AeronAsyncDestination, AeronCError>
pub fn async_remove_destination( &self, client: &Aeron, destination: &CStr, ) -> Result<AeronAsyncDestination, AeronCError>
Unlike Self::add_destination, Aeron’s C API has no ..._destination_cancel
for this in-flight operation, so (as with add_destination) dropping the returned
AeronAsyncDestination before it resolves only logs the generic
“resource likely leaked” warning. It does not stop the removal.
Sourcepub fn remove_destination(
&self,
destination: &CStr,
timeout: Duration,
) -> Result<(), AeronCError>
pub fn remove_destination( &self, destination: &CStr, timeout: Duration, ) -> Result<(), AeronCError>
Remove destination (previously added via Self::add_destination), polling
until the driver acknowledges or timeout elapses. The owning Aeron client is
retrieved automatically from the publication’s dependency graph. Pass it
explicitly via Self::async_remove_destination only when you hold it already.
Sourcepub fn async_remove_destination_by_id(
&self,
client: &Aeron,
destination_registration_id: i64,
) -> Result<AeronAsyncDestination, AeronCError>
pub fn async_remove_destination_by_id( &self, client: &Aeron, destination_registration_id: i64, ) -> Result<AeronAsyncDestination, AeronCError>
Unlike Self::add_destination, Aeron’s C API has no ..._destination_cancel
for this in-flight operation, so dropping the returned AeronAsyncDestination
before it resolves only logs the generic “resource likely leaked” warning. It
does not stop the removal.
Sourcepub fn remove_destination_by_id(
&self,
destination_registration_id: i64,
timeout: Duration,
) -> Result<(), AeronCError>
pub fn remove_destination_by_id( &self, destination_registration_id: i64, timeout: Duration, ) -> Result<(), AeronCError>
Remove the destination identified by destination_registration_id (as returned by
AeronAsyncDestination::get_registration_id after adding it), polling
until the driver acknowledges or timeout elapses. The owning Aeron client is
retrieved automatically from the publication’s dependency graph. Pass it
explicitly via Self::async_remove_destination_by_id only when you hold it
already.
Source§impl AeronPublication
impl AeronPublication
Sourcepub fn offer_raw<H: AeronReservedValueSupplierCallback>(
&self,
buffer: &[u8],
reserved_value_supplier: Option<&Handler<H>>,
) -> i64
pub fn offer_raw<H: AeronReservedValueSupplierCallback>( &self, buffer: &[u8], reserved_value_supplier: Option<&Handler<H>>, ) -> i64
Raw, branch-free variant of Self::offer: returns the new stream position, or a
negative Aeron sentinel (see AeronOfferError::from_position).
Distinct name from the generated offer method (different signatures)
to avoid macro-hygiene name conflicts.
Sourcepub fn try_claim_raw(
&self,
length: usize,
buffer_claim: &AeronBufferClaim,
) -> i64
pub fn try_claim_raw( &self, length: usize, buffer_claim: &AeronBufferClaim, ) -> i64
Raw, branch-free variant of Self::try_claim: position or negative sentinel.
Sourcepub fn offer_with_reserved_value<H: AeronReservedValueSupplierCallback>(
&self,
buffer: &[u8],
reserved_value_supplier: Option<&Handler<H>>,
) -> Result<i64, AeronOfferError>
pub fn offer_with_reserved_value<H: AeronReservedValueSupplierCallback>( &self, buffer: &[u8], reserved_value_supplier: Option<&Handler<H>>, ) -> Result<i64, AeronOfferError>
Self::offer with a reserved-value supplier.
Sourcepub fn try_claim_owned(
&self,
length: usize,
) -> Result<AeronClaim<'_>, AeronOfferError>
pub fn try_claim_owned( &self, length: usize, ) -> Result<AeronClaim<'_>, AeronOfferError>
Zero-copy claim returning a RAII AeronClaim that is auto-aborted on
drop unless explicitly committed or aborted.
Sourcepub fn offer_parts(&self, parts: &[&[u8]]) -> Result<i64, AeronOfferError>
pub fn offer_parts(&self, parts: &[&[u8]]) -> Result<i64, AeronOfferError>
Gathering (vectored) publish: offer up to MAX_OFFER_PARTS buffers as ONE
message without concatenating them first: no allocation, and the parts are
copied straight into the term buffer, as offer copies its one buffer.
This is the header+payload send: instead of building a Vec per message
(vec.extend(header); vec.extend(payload); offer(&vec)), pass the parts:
publication.offer_parts(&[&header_bytes, payload])?;The aeron_iovec_t array is built on the stack. Same typed-error semantics
as Self::offer. Returns AeronOfferError::TooManyParts if more than
MAX_OFFER_PARTS parts are passed (use Self::offerv with your own
iovec array for larger gathers).
Sourcepub fn status(&self) -> AeronStatus
pub fn status(&self) -> AeronStatus
High-level connection state derived from the publication handle.
Sourcepub fn registration_id(&self) -> Result<i64, AeronCError>
pub fn registration_id(&self) -> Result<i64, AeronCError>
Accessor for the registration id (no direct C accessor exists;
backed by Self::get_constants). session_id, stream_id and channel
have cheap direct getters, so prefer those; for registration_id /
max_payload_length in a hot loop, call Self::get_constants once and
reuse the returned AeronPublicationConstants.
Sourcepub fn max_payload_length(&self) -> Result<usize, AeronCError>
pub fn max_payload_length(&self) -> Result<usize, AeronCError>
Accessor for the max payload length (see Self::registration_id).
Source§impl AeronPublication
impl AeronPublication
Sourcepub fn offer(&self, buffer: &[u8]) -> Result<i64, AeronOfferError>
pub fn offer(&self, buffer: &[u8]) -> Result<i64, AeronOfferError>
Non-blocking publish of buffer, returning the new stream position.
Typed-error wrapper over Self::offer_raw; see
AeronOfferError::is_retryable for retry-loop guidance.
Sourcepub fn try_claim(
&self,
length: usize,
buffer_claim: &AeronBufferClaim,
) -> Result<i64, AeronOfferError>
pub fn try_claim( &self, length: usize, buffer_claim: &AeronBufferClaim, ) -> Result<i64, AeronOfferError>
Zero-copy claim with typed errors. See Self::try_claim_owned for RAII.
Trait Implementations§
Source§impl Clone for AeronPublication
impl Clone for AeronPublication
Source§fn clone(&self) -> AeronPublication
fn clone(&self) -> AeronPublication
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more