1/* @ajax/mesh-sched-needs: the fleet scheduler's side of a program's needs. The data (Needs, Term,
2 * Replicas, Migrate) is @ajax/mesh-manifest-needs's `mesh_needs`; this package adds what needs the
3 * scheduler: Term::matches against a member, the one whitespace-free token the fleet's document
4 * carries ("b=cuda;ar=-;mm=0;..."), and the one-line summary `sched` prints. */
5#ifndef MESH_SCHED_NEEDS_H
6#define MESH_SCHED_NEEDS_H
78#include "mesh/needs.h"
9#include "mesh/mt.h"
10#include "mesh/sched_member.h"
1112#include <stdbool.h>
13#include <stdint.h>
1415/* A backend term matches the member's GPU executor; a host the full or the short hostname;
16 * a system the member's id; an arch the member's arch. */
17bool msn_term_matches(const mesh_term *t, const msm_member *m);
18mesh_term msn_term_new(mesh_term_kind kind, const char *s, uint32_t system);
19/* Appends to a term list / a string list (both grown by one; t is taken, s is copied). */
20void msn_terms_push(mesh_term **v, size_t *n, mesh_term t);
21void msn_strs_push(char ***v, size_t *n, const char *s);
22/* A string list joined by sep ("" when empty), and membership. */
23char *msn_strs_join(char *const *v, size_t n, const char *sep);
24bool msn_strs_has(char *const *v, size_t n, const char *s);
25/* "-" or the words joined by ','. */
26char *msn_terms_text(const mesh_term *v, size_t n);
2728/* By-value conveniences over mesh_needs_default / mesh_needs_copy. */
29mesh_needs msn_default(void);
30mesh_needs msn_clone(const mesh_needs *n);
3132char *msn_encode(const mesh_needs *n);
33/* The document's token back; on error *err is the Rust's message and *out holds nothing. */
34bool msn_decode(const char *s, mesh_needs *out, char **err);
35/* One line for `sched` (only what differs from the defaults). */
36char *msn_summary(const mesh_needs *n);
37/* "all" or the count. */
38char *msn_replicas_word(mesh_replicas r);
3940#endif