Skip to main content

RawOutput

Struct RawOutput 

Source
pub struct RawOutput { /* private fields */ }
Expand description

An untyped publishing handle for one of the node’s outputs.

Implementations§

Source§

impl RawOutput

Source

pub fn send_arrow<A>( &mut self, value: &A, metadata: Metadata, ) -> ArrowSendResult<()>
where A: ?Sized, for<'a> RecordBatch: TryFrom<&'a A, Error = InteropError>,

Available on crate feature arrow-interop only.

Publishes an arrow-rs value (blueprint §9.1’s send_arrow).

A is any type astrs-data’s arrow-interop bridge can convert into a RecordBatch — in practice arrow_array::RecordBatch. See the module docs for why the bound is written that way instead of naming the arrow type.

§Errors

ArrowSendError::Interop when the arrow value’s layout has no AstRS counterpart, ArrowSendError::Send for whatever RawOutput::send_batch reports.

Source§

impl RawOutput

Source

pub fn new(shared: Arc<SessionShared>, id: DataId) -> Self

A handle for id on shared.

Source

pub const fn id(&self) -> &DataId

The output’s id.

Source

pub fn plane(&self) -> RoutePlane

The plane this output is publishing on right now (§6.3).

Source

pub const fn segment(&self) -> Option<&ShmSegmentSpec>

The segment this output publishes into, once upgraded.

Source

pub fn consumers(&self) -> &[PortRef]

The consumers the daemon reported at upgrade time.

Source

pub fn zero_copy_threshold(&self) -> u64

The byte count at or above which a payload takes the zero-copy plane.

Source

pub fn refresh(&mut self)

Applies any pending route change (§6.3).

Called before every publish; also public so a node can observe a transition at a moment of its choosing.

Source

pub fn send_bytes( &mut self, bytes: impl AsRef<[u8]>, metadata: Metadata, ) -> Result<()>

Publishes raw payload bytes, which must already be an Arrow IPC stream (§6.1).

§Errors

NodeError::PayloadTooLarge over the negotiated frame budget, NodeError::DaemonGone once the session has ended, and NodeError::UnknownOutput after RawOutput::close.

Source

pub fn send_batch( &mut self, batch: &RecordBatch, metadata: Metadata, ) -> Result<()>

Encodes and publishes a record batch (§6.1).

§Errors

NodeError::Ipc when the batch cannot be encoded, plus whatever RawOutput::send_bytes reports.

Source

pub fn send_array(&mut self, array: ArrayRef, metadata: Metadata) -> Result<()>

Publishes one column as a whole payload (§6.1’s single-payload-column convention).

The shorthand behind blueprint §9.1’s send_arrow(ArrayRef) for a caller that already holds a single ArrayRef — including one an arrow-rs array became through astrs_data::interop::from_arrow_array, which is how an arrow_array::ArrayRef reaches this output without this crate depending on arrow-rs (see arrow’s module docs). Unfeatured, because nothing about it needs the bridge.

§Errors

As RawOutput::send_batch.

Source

pub fn send_slice(&mut self, bytes: &[u8], metadata: Metadata) -> Result<()>

Publishes an already-encoded payload.

The one place both planes meet: everything above funnels here.

§Errors

As RawOutput::send_bytes.

Source

pub fn allocate(&mut self, len: usize) -> Result<OutputSample<'_>>

Reserves len bytes to write into, without copying (§9.1).

On the zero-copy plane the returned buffer is the ring slot; on the daemon path it is an owned heap buffer that the same OutputSample::send publishes inline. A node therefore writes one code path and gets the best plane available at that instant.

§Errors

NodeError::PayloadTooLarge over the frame budget, and NodeError::UnknownOutput after RawOutput::close.

Source

pub fn close(&mut self) -> Result<()>

Tells the daemon this output will produce nothing further, as a deliberate call from a node that goes on running (§7.3 NodeRequest::OutputDone).

Idempotent.

§What the daemon does with it, and why the spelling matters

OutputDone is what blueprint §12 calls an explicit output-close on a live process: the daemon tells this port’s consumers ProducerFinished at once, because nothing about the call predicts the node’s exit and making a live graph wait for one would stall it.

RawOutput::drop deliberately does not use this spelling — see its own documentation.

§Errors

NodeError::DaemonGone once the session has ended.

Source

pub const fn is_closed(&self) -> bool

Whether RawOutput::close has been called.

Source

pub fn metadata(&self) -> Metadata

A fresh metadata block stamped with this node’s clock (§4.3).

Source

pub fn session(&self) -> &Arc<SessionShared> ⓘ

The session this output publishes through.

Trait Implementations§

Source§

impl Debug for RawOutput

Source§

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

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

impl Drop for RawOutput

Source§

fn drop(&mut self)

Closing an output on drop is what makes a node that simply returns from main produce an InputClosed downstream rather than a mysterious silence.

It sends NodeRequest::CloseOutputs rather than NodeRequest::OutputDone, and the difference is not cosmetic. A handle that is going away because its owner is going away carries no evidence about how the process ends: a node that publishes, returns from main and exits non-zero drops this handle first, and calling that “the producer finished” tells every consumer the opposite of what happened. §12’s rule is written on exactly this distinction — the daemon holds a teardown closure until the reap resolves the exit status, and then closes with ProducerCrashed or ProducerFinished accordingly. Sending the explicit spelling here would make ProducerCrashed unreachable for every node that closes on the way out, which is every node written in the §9.1 style.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> MaybeDebug for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more