hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

types.ha (1017B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 use errors;
      5 use fs;
      6 use io;
      7 
      8 // Represents a "null" file descriptor, e.g. /dev/null.
      9 export type nullfd = void;
     10 
     11 // Used to close a file descriptor which does not have the CLOEXEC flag set.
     12 export type closefd = void;
     13 
     14 export type command = struct {
     15 	platform: platform_cmd,
     16 	argv: []str,
     17 	env: []str,
     18 	files: []((io::file | nullfd | closefd), io::file),
     19 	dir: str,
     20 };
     21 
     22 // Returned when path resolution fails to find a command by its name.
     23 export type nocmd = !void;
     24 
     25 // All errors that can be returned from os::exec.
     26 export type error = !(nocmd | ...errors::error | io::error | fs::error);
     27 
     28 // Returns a human-readable message for the given error.
     29 export fn strerror(err: error) const str = {
     30 	match (err) {
     31 	case nocmd =>
     32 		return "Command not found";
     33 	case let err: errors::error =>
     34 		return errors::strerror(err);
     35 	case let err: io::error =>
     36 		return io::strerror(err);
     37 	case let err: fs::error =>
     38 		return fs::strerror(err);
     39 	};
     40 };