pub struct PersistentChild {
pub stdin: Option<PersistentWriter>,
/* private fields */
}Expand description
A child process that will persist over multiple reload cycles.
This child makes use of interprocess’s local sockets for
communication. This is because the process will be spawned by
the duat executor, and communication between it and the config
child process won’t be possible by regular stdio.
Unless you call PersistentChild::kill, duat will assume
that you want it to be kept alive for future reloads.
§Later retrieval
If you want to retrieve this PersistentChild on a future
reload cycle. You will need to store it by calling
storage::store, from duat’s storage module. You can
only do this once, trying it again will (logically) cause a
panic.
Since this struct implements Decode and
Encode, it can be stored and retrieved, even if
it is part of another struct.
If you don’t call storage::store, it is assumed that you no
longer need the process, and it will be killed.
§Unread bytes
When reloading Duat, the stdin, stdout and stderr processes are guaranteed to not lose any bytes.
This is only the case, however, if you don’t have some sort of buffering and/or aren’t doing a deserialization attempt with said data.
If you want to do deserialization (via Decode),
you will want to use PersistentReader::decode_bytes_as.
This method will fail to decode if a reload is requested
midway through reading, but the bytes will be saved for
the next reload cycle, where you can start decoding again.
Fields§
§stdin: Option<PersistentWriter>The standard input of the Child.
This struct will send the bytes to an ipc enabled
LocalSocketStream, which will in turn be sent to the
process indirectly, since said process is owned by the
parent executor, not the child.
Implementations§
Source§impl PersistentChild
impl PersistentChild
Sourcepub fn get_stdout(&self) -> Option<PersistentReader>
pub fn get_stdout(&self) -> Option<PersistentReader>
The standard output of the Child.
This reader is already buffered, so you don’t need to wrap
it in a BufReader to use it efficiently.
In order to use this correctly, you must follow one of three scenarios:
- A reading loop that never stops. This is the most common usecase.
- If you are going to stop, make sure that the reader is
dropped or that you have called
PersistentReader::give_back. This is to ensure that any unread bytes are stored correctly when reloading Duat. - If the child has been killed, then you don’t need to do anything in particular.
For decoding bincode::Decode types, you should make
use of the PersistentReader::decode_bytes_as function,
since that one is not prone to losses if it is interrupted
by a reload.
Sourcepub fn get_stderr(&self) -> Option<PersistentReader>
pub fn get_stderr(&self) -> Option<PersistentReader>
The standard error of the Child.
This reader is already buffered, so you don’t need to wrap
it in a BufReader to use it efficiently.
In order to use this correctly, you must follow one of three scenarios:
- A reading loop that never stops. This is the most common usecase.
- If you are going to stop, make sure that the reader is
dropped or that you have called
PersistentReader::give_back. This is to ensure that any unread bytes are stored correctly when reloading Duat. - If the child has been killed, then you don’t need to do anything in particular.