pub struct ProcessOutput {
pub entity: Entity,
/* private fields */
}Fields§
§entity: EntityImplementations§
Source§impl ProcessOutput
impl ProcessOutput
Sourcepub fn all(&self) -> &str
pub fn all(&self) -> &str
The whole output string generated by the program.
Does not include the final terminating newline.
Sourcepub fn lines(&self) -> Lines<'_>
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
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}Additional examples can be found in:
Trait Implementations§
Source§impl Debug for ProcessOutput
impl Debug for ProcessOutput
impl Message for ProcessOutput
Auto Trait Implementations§
impl Freeze for ProcessOutput
impl RefUnwindSafe for ProcessOutput
impl Send for ProcessOutput
impl Sync for ProcessOutput
impl Unpin for ProcessOutput
impl UnwindSafe for ProcessOutput
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn 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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
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)
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
impl<T> DowncastSend for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.