Skip to main content

KStream

Struct KStream 

Source
pub struct KStream<K, V, KS = <K as DefaultSerde>::Serde, VS = <V as DefaultSerde>::Serde> { /* private fields */ }

Implementations§

Source§

impl<K, V, KS, VS> KStream<K, V, KS, VS>

Source

pub fn with_key_serde<NewKS>(self, serde: NewKS) -> KStream<K, V, NewKS, VS>

Source

pub fn with_value_serde<NewVS>(self, serde: NewVS) -> KStream<K, V, KS, NewVS>

Source§

impl<K, V, KS, VS> KStream<K, V, KS, VS>
where K: Any + Send + Sync + Clone, V: Any + Send + Clone, KS: Clone, VS: Clone,

Source

pub fn map_values<V2, F>( &self, f: F, ) -> KStream<K, V2, KS, <V2 as DefaultSerde>::Serde>
where V2: DefaultSerde + Any + Send + Clone, F: Fn(&V) -> V2 + Clone + Send + Sync + 'static,

mapValues: transform each value, key unchanged. Not key-changing.

Source

pub fn filter<F>(&self, predicate: F) -> KStream<K, V, KS, VS>
where K: Default, F: Fn(&K, &V) -> bool + Clone + Send + Sync + 'static,

filter: keep records where predicate(key, value) is true.

Source

pub fn filter_not<F>(&self, predicate: F) -> KStream<K, V, KS, VS>
where K: Default, F: Fn(&K, &V) -> bool + Clone + Send + Sync + 'static,

filterNot: keep records where predicate(key, value) is false.

Source

pub fn map<K2, V2, F>( &self, f: F, ) -> KStream<K2, V2, <K2 as DefaultSerde>::Serde, <V2 as DefaultSerde>::Serde>
where K: Default, K2: DefaultSerde + Any + Send + Clone, V2: DefaultSerde + Any + Send + Clone, F: Fn(&K, &V) -> (K2, V2) + Clone + Send + Sync + 'static,

map: transform key and value. Key-changing.

Source

pub fn select_key<K2, F>( &self, f: F, ) -> KStream<K2, V, <K2 as DefaultSerde>::Serde, VS>
where K: Default, K2: DefaultSerde + Any + Send + Clone, F: Fn(&K, &V) -> K2 + Clone + Send + Sync + 'static,

selectKey: rewrite the key, value unchanged. Key-changing.

Source

pub fn select_key_with_serde<K2, GKS, F>( &self, f: F, key_serde: GKS, ) -> KStream<K2, V, GKS, VS>
where K: Default, K2: Any + Send + Clone, GKS: Serde<K2> + Clone + 'static, F: Fn(&K, &V) -> K2 + Clone + Send + Sync + 'static,

selectKey with an explicit key serde. Key-changing.

Source

pub fn flat_map<K2, V2, IT, F>( &self, f: F, ) -> KStream<K2, V2, <K2 as DefaultSerde>::Serde, <V2 as DefaultSerde>::Serde>
where K: Default, K2: DefaultSerde + Any + Send + Clone, V2: DefaultSerde + Any + Send + Clone, IT: IntoIterator<Item = (K2, V2)> + 'static, F: Fn(&K, &V) -> IT + Clone + Send + Sync + 'static,

flatMap: one record → zero or more (K2, V2). Key-changing.

Source

pub fn flat_map_values<V2, IT, F>( &self, f: F, ) -> KStream<K, V2, KS, <V2 as DefaultSerde>::Serde>
where V2: DefaultSerde + Any + Send + Clone, IT: IntoIterator<Item = V2> + 'static, F: Fn(&V) -> IT + Clone + Send + Sync + 'static,

flatMapValues: one record → zero or more V2, key unchanged.

Source

pub fn peek<F>(&self, f: F) -> KStream<K, V, KS, VS>
where K: Default, F: Fn(&K, &V) + Clone + Send + Sync + 'static,

peek: observe each record, then forward it unchanged.

Source

pub fn foreach<F>(self, f: F)
where K: Default, F: Fn(&K, &V) + Clone + Send + Sync + 'static,

foreach: terminal side-effect on each record (consumes the stream).

Source

pub fn to_explicit<KS2, VS2>( self, topic: impl Into<String>, produced: impl Into<Produced<KS2, VS2>>, )
where KS2: SerdeAssociate + Serde<K> + Clone, VS2: SerdeAssociate + Serde<V> + Clone,

to: write the stream to a topic through a sink (consumes the stream).

Source

pub fn to(self, topic: impl Into<String>)
where KS: SerdeAssociate + Serde<K> + Clone, VS: SerdeAssociate + Serde<V> + Clone,

Write the stream to a topic using the default/carried serdes of the stream.

Source

pub fn merge(&self, other: &KStream<K, V, KS, VS>) -> KStream<K, V, KS, VS>

merge: union this stream with other (same K/V). Both feed one node.

Source

pub fn join_table<VT, VO, F, VTS>( &self, table: &KTable<K, VT, KS, VTS>, joiner: F, ) -> KStream<K, VO, KS, <VO as DefaultSerde>::Serde>
where VT: Any + Send + Clone, VO: DefaultSerde + Any + Send + Clone, VTS: Clone, F: Fn(&V, &VT) -> VO + Clone + Send + Sync + 'static,

join (inner stream-table join): look each stream record up in table.

For each record on this stream, this method looks the record’s key up in table’s materialized store. Only when a value is present, it forwards joiner(&stream_value, &table_value) keyed by the same key. It drops records whose key is absent from the table. This is an inner join.

table must be materialized, that is, sourced through StreamsBuilder::table or any materialized op. The join reads its store by name. The join declares the stream side and the table’s source topic as a copartition group (KIP-1071), so the streams-group coordinator co-locates their partitions.

The stream key must be unchanged relative to its source partitioning, because a stream-table join is partition-local. If a key-changing op such as map, select_key, flat_map, or group_by comes before the join, call repartition first to re-partition by the new key. If you do not, join_table panics.

§Naming vs the JVM

The JVM overloads join for both stream-table and (windowed) stream-stream joins. Rust cannot have two inherent methods of the same name and differing arity, so the stream-table forms are named join_table/left_join_table here, leaving the plain join/left_join for the windowed stream-stream join (see KStream::join).

§Panics

Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.

Source

pub fn left_join_table<VT, VO, F, VTS>( &self, table: &KTable<K, VT, KS, VTS>, joiner: F, ) -> KStream<K, VO, KS, <VO as DefaultSerde>::Serde>
where VT: Any + Send + Clone, VO: DefaultSerde + Any + Send + Clone, VTS: Clone, F: Fn(&V, Option<&VT>) -> VO + Clone + Send + Sync + 'static,

leftJoin (left stream-table join): like join_table but always forwards a record for every stream record. On a table miss the joiner receives None for the table-side value. See join_table for the naming-vs-JVM note.

Source

pub fn join_table_with<VT, VO, F, VTS>( &self, table: &KTable<K, VT, KS, VTS>, joiner: F, join_config: Joined, ) -> KStream<K, VO, KS, <VO as DefaultSerde>::Serde>
where VT: Any + Send + Sync + Clone, VO: DefaultSerde + Any + Send + Clone, VTS: Clone, KS: Serde<K> + Clone + 'static, VS: Serde<V> + Clone + 'static, V: Sync, F: Fn(&V, &VT) -> VO + Clone + Send + Sync + 'static,

join with Joined config (KIP-923 grace path).

This method is identical to join_table when joined.grace is None. When a grace period is set, the join buffers each stream record into a JoinGraceBufferStore. It drains the buffer as-of the record’s own timestamp once the grace horizon passes. Out-of-order stream records therefore join against the table version that was current at the record’s own timestamp.

Grace requires the table to be versioned. See Materialized::as_versioned. grace must be strictly less than the table’s history_retention.

§Panics

Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.

Source

pub fn left_join_table_with<VT, VO, F, VTS>( &self, table: &KTable<K, VT, KS, VTS>, joiner: F, join_config: Joined, ) -> KStream<K, VO, KS, <VO as DefaultSerde>::Serde>
where VT: Any + Send + Sync + Clone, VO: DefaultSerde + Any + Send + Clone, VTS: Clone, KS: Serde<K> + Clone + 'static, VS: Serde<V> + Clone + 'static, V: Sync, F: Fn(&V, Option<&VT>) -> VO + Clone + Send + Sync + 'static,

leftJoin with Joined config (KIP-923 grace path). Like left_join_table but, when joined.grace is set, wires the grace buffer + as-of drain (see join_table_with). On a table miss at drain time the joiner receives None.

Source

pub fn join_global<GK, VG, VR, KM, J, GKS, VGS>( &self, global: &GlobalKTable<GK, VG, GKS, VGS>, key_mapper: KM, joiner: J, ) -> KStream<K, VR, KS, <VR as DefaultSerde>::Serde>
where GK: Any + Send + Sync + 'static, VG: Any + Send + Clone, VR: DefaultSerde + Any + Send + Clone, GKS: Clone, VGS: Clone, KM: Fn(&K, &V) -> GK + Clone + Send + Sync + 'static, J: Fn(&V, &VG) -> VR + Clone + Send + Sync + 'static,

join (inner stream-globaltable join): look each record up in global.

For each record on this stream, this method computes the lookup key gk = key_mapper(&streamKey, &streamValue) and looks it up in global’s fully-replicated store. Only on a hit, it forwards joiner(&stream_value, &global_value) keyed by the stream key with the stream timestamp. It drops records whose derived key is absent.

The lookup key is derived from the record, unlike join_table, so it can differ from the stream key. A GlobalKTable is fully replicated, so there is no copartitioning, no repartition, and no key-changing assertion. Any record can look up any key on every instance.

§Panics

Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.

Source

pub fn left_join_global<GK, VG, VR, KM, J, GKS, VGS>( &self, global: &GlobalKTable<GK, VG, GKS, VGS>, key_mapper: KM, joiner: J, ) -> KStream<K, VR, KS, <VR as DefaultSerde>::Serde>
where GK: Any + Send + Sync + 'static, VG: Any + Send + Clone, VR: DefaultSerde + Any + Send + Clone, GKS: Clone, VGS: Clone, KM: Fn(&K, &V) -> GK + Clone + Send + Sync + 'static, J: Fn(&V, Option<&VG>) -> VR + Clone + Send + Sync + 'static,

leftJoin (left stream-globaltable join): like join_global but always forwards a record for every stream record. On a global-store miss the joiner receives None for the global-side value.

Source

pub fn join<V2, VO, F, V2S>( &self, other: &KStream<K, V2, KS, V2S>, joiner: F, windows: JoinWindows, stream_joined: StreamJoined<KS, VS, V2S>, ) -> KStream<K, VO, KS, <VO as DefaultSerde>::Serde>
where V2: Any + Send + Sync + Clone, VO: DefaultSerde + Any + Send + Clone, F: Fn(&V, &V2) -> VO + Clone + Send + Sync + 'static, KS: Serde<K> + Clone + 'static, VS: Serde<V> + Clone + 'static, V2S: Serde<V2> + Clone + 'static, V: Send + Sync,

join (windowed inner stream-stream join): match records over a window.

For each record on either stream, the join puts the record into its own JoinWindowStore and fetches the OTHER stream’s store over the join window. It forwards one output per match, keyed by the same key. A left record at t matches right records with a timestamp in [t - before, t + after]. The rule is symmetric: the per-side OTHER processor swaps before and after, so the rule holds whichever side drives the record.

The join lowers to a THIS processor fed by this stream, an OTHER processor fed by other, and a MERGE node that unions the two outputs. This mirrors KTable::join’s dual+merge shape. Each side puts into its own retainDuplicates join-window store and reads the other side’s store. Each side connects to BOTH stores, so the grouping pass folds A, B, both stores, and the two join nodes into one copartitioned subtopology. When both streams are single-source-topic streams, the join declares their source topics as a copartition group (KIP-1071).

Both stream keys must be unchanged relative to their source partitioning. You must call repartition() after a key-changing op upstream. If you do not, the join panics.

§Naming vs the JVM

The JVM overloads join for stream-table and stream-stream. Rust cannot, so the windowed stream-stream join keeps join/left_join while the stream-table forms are join_table/ left_join_table.

§Panics

Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.

Source

pub fn left_join<V2, VO, F, V2S>( &self, other: &KStream<K, V2, KS, V2S>, joiner: F, windows: JoinWindows, stream_joined: StreamJoined<KS, VS, V2S>, ) -> KStream<K, VO, KS, <VO as DefaultSerde>::Serde>
where V2: Any + Send + Sync + Clone, VO: DefaultSerde + Any + Send + Clone, F: Fn(&V, Option<&V2>) -> VO + Clone + Send + Sync + 'static, KS: Serde<K> + Clone + 'static, VS: Serde<V> + Clone + 'static, V2S: Serde<V2> + Clone + 'static, V: Send + Sync,

leftJoin (windowed left stream-stream join): emit unmatched left records.

Every record on THIS (left) stream that finds no match in the OTHER (right) window emits joiner(&this, None) once that record’s window closes. Stream time drives the window close (KIP-633). Matched records emit joiner(&this, Some(&other)), as in the inner join. The right side never emits a non-join.

§Panics

Panics if synchronized client state is poisoned or a response violates an invariant established by protocol validation.

Source

pub fn outer_join<V2, VO, F, V2S>( &self, other: &KStream<K, V2, KS, V2S>, joiner: F, windows: JoinWindows, stream_joined: StreamJoined<KS, VS, V2S>, ) -> KStream<K, VO, KS, <VO as DefaultSerde>::Serde>
where V2: Any + Send + Sync + Clone, VO: DefaultSerde + Any + Send + Clone, F: Fn(Option<&V>, Option<&V2>) -> VO + Clone + Send + Sync + 'static, KS: Serde<K> + Clone + 'static, VS: Serde<V> + Clone + 'static, V2S: Serde<V2> + Clone + 'static, V: Send + Sync,

outerJoin (windowed outer stream-stream join): emit from either side.

Every record on EITHER side that finds no match emits joiner(Some, None) or joiner(None, Some) once its window closes (KIP-633). Matched records emit joiner(Some, Some).

Source

pub fn repartition<KS2, VS2>( &self, repartitioned: Repartitioned<KS2, VS2>, ) -> KStream<K, V, KS2, VS2>
where KS2: Serde<K> + Clone + 'static, VS2: Serde<V> + Clone + 'static,

repartition: force a repartition through an internal topic.

This op lowers as sink → add_repartition_topic → source. It is the same pattern that the implicit repartition before a stateful aggregation uses. The repartition topic name is <app_id>-<name>-repartition. <name> is the explicit Repartitioned name when set, otherwise an auto-name minted from the counter.

Byte-exactness vs JVM: the JVM assigns a distinct KSTREAM-REPARTITION- counter for standalone repartition() calls. No golden fixture validates that counter. The bar here is functional correctness: no panic, and records flow through.

Source

pub fn split(&self) -> BranchedStream<K, V, KS, VS>

split: begin a branching fan-out.

Returns a BranchedStream builder. Individual branch calls on that builder create filtered child streams. The split itself adds no node to the topology. Each branch call creates a filter-backed child wired directly to this stream’s node.

Simplification vs JVM: each branch receives a record when its predicate matches, not just the first matching branch. For mutually-exclusive predicates the behaviour is identical to the JVM first-match-wins semantics.

Source

pub fn group_by_key_explicit<GKS, GVS>( &self, grouped: impl Into<Grouped<GKS, GVS>>, ) -> KGroupedStream<K, V>
where GKS: Serde<K> + Clone + 'static, GVS: Serde<V> + Clone + 'static,

groupByKey: group by the existing key, ready for an aggregation.

This op records no graph node. A terminal count, reduce, or aggregate call records the optional repartition and the aggregate node. The returned KGroupedStream carries two things: whether the upstream key lineage is key-changing, which forces the aggregation to insert a repartition, and a typed repartition-lowering thunk built from the Grouped serdes.

Source

pub fn group_by_key(&self) -> KGroupedStream<K, V>
where KS: Serde<K> + Clone + 'static, VS: Serde<V> + Clone + 'static,

groupByKey using the stream’s existing serdes.

Source

pub fn group_by<GKS, GVS, F>( &self, f: F, grouped: impl Into<Grouped<GKS, GVS>>, ) -> KGroupedStream<GKS::Target, V>
where K: Default, GKS: SerdeAssociate + Serde<GKS::Target> + Clone + 'static, GVS: SerdeAssociate + Serde<V> + Clone + 'static, GKS::Target: Any + Send + Sync + Clone, F: Fn(&K, &V) -> GKS::Target + Clone + Send + Sync + 'static,

groupBy: re-key with f, then group by the new key.

This op is equivalent to select_key(f).group_by_key_explicit(grouped). The key change forces a repartition before any later aggregation.

Source

pub fn process<KOut, VOut, PS>( &self, supplier: PS, store_names: impl IntoIterator<Item = impl Into<String>>, ) -> KStream<KOut, VOut, <KOut as DefaultSerde>::Serde, <VOut as DefaultSerde>::Serde>
where KOut: DefaultSerde + Any + Send + Sync + Clone, VOut: DefaultSerde + Any + Send + Clone, PS: ProcessorSupplier<K, V, KOut, VOut> + Clone + 'static,

process: attach a custom Processor-API node that may rewrite the key.

supplier is any user ProcessorSupplier, for example a || MyProc closure. store_names names the stores that StreamsBuilder::add_state_store registered and that the processor reads and writes through ProcessorContext::get_state_store. This method looks up each named store’s connect thunk now, so you must add the store before this call. Lowering then invokes each thunk to register the store, emit its compact <app>-<store>-changelog changelog, and connect the store to this processor node.

This op mirrors the JVM KStream.process. It treats the result as key-changing, because the processor may call forward with any key. The single-source-topic lineage therefore breaks, and a downstream aggregation or join must repartition first.

§Panics

Panics if any name in store_names was not registered through add_state_store.

Source

pub fn process_values<VOut, PS>( &self, supplier: PS, store_names: impl IntoIterator<Item = impl Into<String>>, ) -> KStream<K, VOut, KS, <VOut as DefaultSerde>::Serde>
where VOut: DefaultSerde + Any + Send + Clone, PS: FixedKeyProcessorSupplier<K, V, VOut> + Clone + 'static,

processValues: attach a custom fixed-key Processor-API node (KIP-820).

The node may rewrite the value but NOT the key.

supplier is any FixedKeyProcessorSupplier, for example a || MyFixedProc closure. store_names names the stores that add_state_store registered and that the processor reads and writes through FixedKeyProcessorContext::get_state_store. As with process, this method looks up each named store’s connect thunk now, so you must add the store before this call. Lowering then invokes each thunk to register the store, emit its compact <app>-<store>-changelog changelog, and connect the store to this processor node.

Unlike process, this op keeps the key. The result is therefore non-key-changing and carries the single-source-topic lineage unchanged, so a downstream aggregation or join needs no repartition. An internal adapter wraps the supplier, so the runtime sees a Processor<K, V, K, VOut>.

§Panics

Panics if any name in store_names was not registered through add_state_store.

Source

pub fn to_table_explicit<NKS, NVS>( &self, materialized: impl Into<Materialized<NKS, NVS>>, ) -> KTable<K, V, NKS, NVS>
where NKS: Serde<K> + Clone + 'static, NVS: Serde<V> + Clone + 'static,

toTable: materialize this stream into a KTable.

The op writes each record into a state store and forwards a Change<V> change-stream that carries the prior store value as old.

to_table carries the key through unchanged, so it never inserts a repartition. The JVM repartitions only when the upstream key is rewritten without a re-group. The store name is Materialized’s explicit name when set, otherwise a fresh KSTREAM-TOTABLE-STATE-STORE- counter. The store gets the standard <app>-<store>-changelog changelog, or no changelog when Materialized::with_logging(false).

Source

pub fn to_table(&self, store_name: impl Into<String>) -> KTable<K, V, KS, VS>
where KS: Serde<K> + Clone + 'static, VS: Serde<V> + Clone + 'static,

Sourced KTable from this stream using the stream’s carried serdes.

Auto Trait Implementations§

§

impl<K, V, KS = <K as DefaultSerde>::Serde, VS = <V as DefaultSerde>::Serde> !RefUnwindSafe for KStream<K, V, KS, VS>

§

impl<K, V, KS = <K as DefaultSerde>::Serde, VS = <V as DefaultSerde>::Serde> !Send for KStream<K, V, KS, VS>

§

impl<K, V, KS = <K as DefaultSerde>::Serde, VS = <V as DefaultSerde>::Serde> !Sync for KStream<K, V, KS, VS>

§

impl<K, V, KS = <K as DefaultSerde>::Serde, VS = <V as DefaultSerde>::Serde> !UnwindSafe for KStream<K, V, KS, VS>

§

impl<K, V, KS, VS> Freeze for KStream<K, V, KS, VS>
where KS: Freeze, VS: Freeze,

§

impl<K, V, KS, VS> Unpin for KStream<K, V, KS, VS>
where KS: Unpin, VS: Unpin,

§

impl<K, V, KS, VS> UnsafeUnpin for KStream<K, V, KS, VS>
where KS: UnsafeUnpin, VS: UnsafeUnpin,

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

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

§

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

§

impl<K, Q> Comparable<Q> for K
where K: Borrow<Q> + ?Sized, Q: Ord + ?Sized,

§

fn compare(&self, key: &Q) -> Ordering

Compare self to key and return their ordering.
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<K, Q> Equivalent<Q> for K
where K: Borrow<Q> + ?Sized, Q: Eq + ?Sized,

§

fn equivalent(&self, key: &Q) -> bool

Compare self to key and return true if they are equal.
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Paint for T
where T: ?Sized,

§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling [Attribute] value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi [Quirk] value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1:

renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the [Condition] value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new [Painted] with a default [Style]. Read more
§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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