imgcli\pipe.mbt
28.6% · 2 / 7 points · 55 linesBackground color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.
- 1
///| - 2
/// # 管道输入输出(`-` 约定) - 3
/// - 4
/// 约定与 ImageMagick / ffmpeg 一致:路径写 `-` 表示 stdin 或 stdout。 - 5
/// 底层能力只在 native 目标存在(见 `stdio_stub.c`);非 native 目标返回 - 6
/// `None` / `false`,由调用方转成 `UnsupportedFormat` 错误,保证四目标同签名。 - 7
- 8
///| - 9
#cfg(target="native") - 10
extern "C" fn read_stdin_ffi() -> Bytes = "moonbit_imgcli_read_stdin" - 11
- 12
///| - 13
#cfg(target="native") - 14
#borrow(data) - 15
extern "C" fn write_stdout_ffi(data : Bytes) -> Unit = "moonbit_imgcli_write_stdout" - 16
- 17
///| - 18
/// 读 stdin 全量字节;非 native 目标返回 `None`。 - 19
#cfg(target="native") - 20
pub fn read_stdin_bytes() -> Bytes? { - 21○
Some(read_stdin_ffi()) - 22
} - 23
- 24
///| - 25
/// 把二进制写到 stdout;非 native 目标返回 `false`。 - 26
#cfg(target="native") - 27
pub fn write_stdout_bytes(data : Bytes) -> Bool { - 28○
write_stdout_ffi(data) - 29
true - 30
} - 31
- 32
///| - 33
#cfg(not(target="native")) - 34
pub fn read_stdin_bytes() -> Bytes? { - 35○
None - 36
} - 37
- 38
///| - 39
#cfg(not(target="native")) - 40
pub fn write_stdout_bytes(data : Bytes) -> Bool { - 41○
ignore(data) - 42
false - 43
} - 44
- 45
///| - 46
/// 路径是否为 stdin 占位符。 - 47
pub fn is_stdin_path(path : String) -> Bool { - 48●
path == "-" - 49
} - 50
- 51
///| - 52
/// 路径是否为 stdout 占位符。 - 53
pub fn is_stdout_path(path : String) -> Bool { - 54●
path == "-" - 55
}