ProcessOutput

Struct ProcessOutput 

Source
pub struct ProcessOutput {
    pub entity: Entity,
    /* private fields */
}

Fields§

§entity: Entity

Implementations§

Source§

impl ProcessOutput

Source

pub fn all(&self) -> &str

The whole output string generated by the program.

Does not include the final terminating newline.

Source

pub fn lines(&self) -> Lines<'_>

An iterator over the lines of the output, as string slices.

Examples found in repository?
examples/kill.rs (line 50)
45fn update(
46    mut process_output_event: MessageReader<ProcessOutput>,
47    mut process_completed_event: MessageReader<ProcessCompleted>,
48) {
49    for process_output in process_output_event.read() {
50        for line in process_output.lines() {
51            println!("Output Line ({:?}): {line}", process_output.entity);
52        }
53    }
54    if let Some(completed) = process_completed_event.read().last() {
55        println!(
56            "Command {:?} completed (Success - {})",
57            completed.entity,
58            completed.exit_status.success()
59        );
60        // Quit the app
61        std::process::exit(0);
62    }
63}
More examples
Hide additional examples
examples/simple.rs (line 28)
23fn update(
24    mut process_output_event: MessageReader<ProcessOutput>,
25    mut process_completed_event: MessageReader<ProcessCompleted>,
26) {
27    for process_output in process_output_event.read() {
28        for line in process_output.lines() {
29            println!("Output Line ({:?}): {line}", process_output.entity);
30        }
31    }
32    if let Some(process_completed) = process_completed_event.read().last() {
33        println!(
34            "Command {:?} completed (Success - {})",
35            process_completed.entity,
36            process_completed.exit_status.success()
37        );
38        // Quit the app
39        std::process::exit(0);
40    }
41}
examples/input.rs (line 32)
26fn update(
27    mut process_output_event: MessageReader<ProcessOutput>,
28    mut process_completed_event: MessageReader<ProcessCompleted>,
29    mut active_processes: Query<&mut Process>,
30) {
31    for process_output in process_output_event.read() {
32        for line in process_output.lines() {
33            println!("{line}");
34        }
35    }
36    if let Ok(mut process) = active_processes.single_mut() {
37        process.println("Bevy").unwrap_or_default();
38    }
39    if let Some(process_completed) = process_completed_event.read().last() {
40        println!(
41            "Command {:?} completed (Success - {})",
42            process_completed.entity,
43            process_completed.exit_status.success()
44        );
45        // Quit the app
46        std::process::exit(0);
47    }
48}
examples/chain_failure.rs (line 44)
38fn update(
39    mut process_output_event: MessageReader<ProcessOutput>,
40    mut process_completed_event: MessageReader<ProcessCompleted>,
41    chain_query: Query<(), With<Chain>>,
42) {
43    for process_output in process_output_event.read() {
44        for line in process_output.lines() {
45            println!("Output Line ({:?}): {line}", process_output.entity);
46        }
47    }
48
49    for process_completed in process_completed_event.read() {
50        println!(
51            "Command {:?} completed (Success - {})",
52            process_completed.entity,
53            process_completed.exit_status.success()
54        );
55    }
56
57    // Check if there are no more Chain components (all chains completed)
58    if chain_query.is_empty() {
59        println!("Chain commands done. Exiting the app.");
60        std::process::exit(0);
61    }
62}
examples/simple_chain.rs (line 40)
34fn update(
35    mut process_output_event: MessageReader<ProcessOutput>,
36    mut process_completed_event: MessageReader<ProcessCompleted>,
37    chain_query: Query<(), With<Chain>>,
38) {
39    for process_output in process_output_event.read() {
40        for line in process_output.lines() {
41            println!("Output Line ({:?}): {line}", process_output.entity);
42        }
43    }
44
45    for process_completed in process_completed_event.read() {
46        println!(
47            "Command {:?} completed (Success - {})",
48            process_completed.entity,
49            process_completed.exit_status.success()
50        );
51    }
52
53    // Check if there are no more Chain components (all chains completed)
54    if chain_query.is_empty() {
55        println!("All chain commands completed. Exiting the app.");
56        std::process::exit(0);
57    }
58}
examples/chain_retries_delay_cleanup.rs (line 48)
42fn update(
43    mut process_output_event: MessageReader<ProcessOutput>,
44    mut process_completed_event: MessageReader<ProcessCompleted>,
45    command_query: Query<(), (With<Chain>, With<Retry>, With<Delay>, With<Cleanup>)>,
46) {
47    for process_output in process_output_event.read() {
48        for line in process_output.lines() {
49            println!("Output Line ({:?}): {line}", process_output.entity);
50        }
51    }
52
53    for process_completed in process_completed_event.read() {
54        println!(
55            "Command {:?} completed (Success - {})",
56            process_completed.entity,
57            process_completed.exit_status.success()
58        );
59    }
60
61    // Check if our entity is done running chain commands
62    if command_query.is_empty() {
63        println!("All commands completed - cleanup performed. Exiting the app.");
64        std::process::exit(0);
65    }
66}

Trait Implementations§

Source§

impl Debug for ProcessOutput

Source§

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

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

impl Message for ProcessOutput
where Self: Send + Sync + 'static,

Auto Trait Implementations§

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> Downcast for T
where T: Any,

Source§

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

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

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

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

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
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> 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
Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. 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.
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
Source§

impl<T> ConditionalSend for T
where T: Send,