Skip to main content

AeronPublication

Struct AeronPublication 

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

Implementations§

Source§

impl AeronPublication

Source

pub fn image_location( dst: &mut [u8], aeron_dir: &CStr, correlation_id: i64, ) -> Result<i32, AeronCError>

Source§

impl<S: ResourceStorage<aeron_publication_t>> AeronPublication<S>

Source

pub fn offerv<AeronReservedValueSupplierHandlerImpl: AeronReservedValueSupplierCallback, AeronReservedValueSupplierHandlerImplPolicy: CallbackPolicy>( &self, iov: &AeronIovec, iovcnt: usize, reserved_value_supplier: Option<&Handler<AeronReservedValueSupplierHandlerImpl, AeronReservedValueSupplierHandlerImplPolicy>>, ) -> i64

Non-blocking publish by gathering buffer vectors into a message.

§Parameters
  • iov array for the vectors
  • iovcnt of the number of vectors
  • reserved_value_supplier to use for setting the reserved value field or NULL.
§Return

the new stream position otherwise a negative error value.

Source

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
  • iov array for the vectors
  • iovcnt of the number of vectors
  • reserved_value_supplier to use for setting the reserved value field or NULL.
§Return

the new stream position otherwise a negative error value.

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 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

Source

pub fn is_closed(&self) -> bool

Has the publication closed?

§Return

true if this publication is closed.

Source

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.

Source

pub unsafe fn constants( &self, constants: &AeronPublicationConstants<impl ResourceStorage<aeron_publication_constants_t>>, ) -> Result<i32, AeronCError>

Fill in a structure with the constants in use by a publication.

§Parameters
  • constants structure 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.

Source

pub fn get_constants( &self, ) -> Result<AeronPublicationConstants<ScopedInline<'_, aeron_publication_constants_t>>, AeronCError>

Fill in a structure with the constants in use by a publication.

Source

pub fn original_registration_id(&self) -> Result<i64, AeronCError>

get_constants()?.original_registration_id(). Call get_constants() once to read several fields

Source

pub fn registration_id(&self) -> Result<i64, AeronCError>

get_constants()?.registration_id(). Call get_constants() once to read several fields

Source

pub fn max_possible_position(&self) -> Result<i64, AeronCError>

get_constants()?.max_possible_position(). Call get_constants() once to read several fields

Source

pub fn position_bits_to_shift(&self) -> Result<usize, AeronCError>

get_constants()?.position_bits_to_shift(). Call get_constants() once to read several fields

Source

pub fn term_buffer_length(&self) -> Result<usize, AeronCError>

get_constants()?.term_buffer_length(). Call get_constants() once to read several fields

Source

pub fn max_message_length(&self) -> Result<usize, AeronCError>

get_constants()?.max_message_length(). Call get_constants() once to read several fields

Source

pub fn max_payload_length(&self) -> Result<usize, AeronCError>

get_constants()?.max_payload_length(). Call get_constants() once to read several fields

Source

pub fn initial_term_id(&self) -> Result<i32, AeronCError>

get_constants()?.initial_term_id(). Call get_constants() once to read several fields

Source

pub fn publication_limit_counter_id(&self) -> Result<i32, AeronCError>

get_constants()?.publication_limit_counter_id(). Call get_constants() once to read several fields

Source

pub fn channel_status_indicator_id(&self) -> Result<i32, AeronCError>

get_constants()?.channel_status_indicator_id(). Call get_constants() once to read several fields

Source

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.

Source

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.

Source

pub fn channel(&self) -> &str

Get the publication’s channel

§Return

channel uri string

Source

pub fn stream_id(&self) -> i32

Get the publication’s stream id

§Return

stream id

Source

pub fn session_id(&self) -> i32

Get the publication’s session id

§Return

session id

Source

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_vec to hold the received addresses
  • address_vec_len available 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

Source

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

Borrow this handle without cloning its owner.

Source

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

Source

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.

Source

pub unsafe fn get_inner_ref(&self) -> &aeron_publication_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 AeronPublication

Source

pub unsafe fn from_ptr( ptr: *mut aeron_publication_t, ) -> AeronPublication<Borrowed<aeron_publication_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 AeronPublication

Source

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 AeronPublication

Source

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 AeronPublication

Source

pub fn is_ready(&self) -> bool

Source§

impl AeronPublication

Source

pub fn async_add_destination( &self, client: &Aeron, uri: &CStr, ) -> Result<AeronAsyncDestination, AeronCError>

Start a destination change. Dropping the operation does not cancel it.

Source

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.

Source

pub fn async_remove_destination( &self, client: &Aeron, uri: &CStr, ) -> Result<AeronAsyncDestination, AeronCError>

Start a destination change. Dropping the operation does not cancel it.

Source

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

pub fn async_remove_destination_by_id( &self, client: &Aeron, destination_registration_id: i64, ) -> Result<AeronAsyncDestination, AeronCError>

Start a destination change. Dropping the operation does not cancel it.

Source

pub fn remove_destination_by_id( &self, destination_registration_id: i64, 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<S: ResourceStorage<aeron_publication_t>> AeronPublication<S>

Source

pub fn offer_raw<H: AeronReservedValueSupplierCallback>( &self, buffer: &[u8], reserved_value_supplier: Option<&Handler<H, impl CallbackPolicy>>, ) -> 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.

Source

pub fn try_claim_raw( &self, length: usize, buffer_claim: &AeronBufferClaim<impl ResourceStorage<aeron_buffer_claim_t>>, ) -> i64

Raw, branch-free variant of Self::try_claim: position or negative sentinel.

Source

pub fn offer_with_reserved_value<H: AeronReservedValueSupplierCallback>( &self, buffer: &[u8], reserved_value_supplier: Option<&Handler<H, impl CallbackPolicy>>, ) -> Result<i64, AeronOfferError>

Self::offer with a reserved-value supplier.

Source

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.

Source

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).

Source

pub fn status(&self) -> AeronStatus

High-level connection state derived from the publication handle.

Source§

impl<S: ResourceStorage<aeron_publication_t>> AeronPublication<S>

Source

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.

Source

pub fn try_claim( &self, length: usize, buffer_claim: &AeronBufferClaim<impl ResourceStorage<aeron_buffer_claim_t>>, ) -> Result<i64, AeronOfferError>

Zero-copy claim with typed errors. See Self::try_claim_owned for RAII.

Trait Implementations§

Source§

impl<S: Clone + ResourceStorage<aeron_publication_t>> Clone for AeronPublication<S>

Source§

fn clone(&self) -> AeronPublication<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_publication_t>> Debug for AeronPublication<S>

Source§

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

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

impl<S: ResourceStorage<aeron_publication_t>> From<&AeronPublication<S>> for *mut aeron_publication_t

Source§

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

Converts to this type from the input type.
Source§

impl<S: ResourceStorage<aeron_publication_t>> From<AeronPublication<S>> for *mut aeron_publication_t

Source§

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

Converts to this type from the input type.
Source§

impl<S: ResourceStorage<aeron_publication_t> + SharedStorage<aeron_publication_t>> Send for AeronPublication<S>

Source§

impl<S: ResourceStorage<aeron_publication_t> + SharedStorage<aeron_publication_t>> Sync for AeronPublication<S>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<S> UnwindSafe for AeronPublication<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.