Mojo struct
Pipe
struct Pipe
Create a pipe for interprocess communication.
Example usage:
pipe().write_bytes("TEST".as_bytes())Fields
- fd_in (
Optional[FileDescriptor]): File descriptor for pipe input. - fd_out (
Optional[FileDescriptor]): File descriptor for pipe output.
Implemented traits
AnyType,
ImplicitlyDestructible
comptime members
__del__is_trivial
comptime __del__is_trivial = False
Methods
__init__
__init__(out self, in_close_on_exec: Bool = True, out_close_on_exec: Bool = True)
Initializes a new Pipe.
Args:
- in_close_on_exec (
Bool): Close the read side of pipe if anexecsyscall is issued in the process. - out_close_on_exec (
Bool): Close the write side of pipe if anexecsyscall is issued in the process.
Raises:
Error: If the pipe could not be created or configured.
__del__
__del__(deinit self)
Ensures pipes input and output file descriptors are closed, when the object is destroyed.
set_input_only
set_input_only(mut self)
Close the output descriptor/ channel for this side of the pipe.
set_output_only
set_output_only(mut self)
Close the input descriptor/ channel for this side of the pipe.
write_bytes
write_bytes(mut self, bytes: Span[Byte, origin])
Writes a span of bytes to the pipe.
Args:
- bytes (
Span): The byte span to write to this pipe.
Raises:
Error: If called on a read-only pipe.
read_bytes
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!