Expand description
gadk-platform: overridable time, UUID and task-execution seams, the ADK tracking header
value, the injectable environment (env), and shared helpers with exact output
formats: double-quoted strings ([go_quote]), shortest round-trip floats
(go_format_float_g), simple one-rune casing (go_to_lower, go_to_upper), query
escaping (go_query_escape), %v-style rendering of a JSON value (go_sprint_value),
RFC 3339 parsing (go_parse_rfc3339), lexical path functions (go_path_clean,
go_path_join, go_path_dir, go_path_base), Unix go_filepath_rel and
go_filepath_is_local, safe resolution of an untrusted relative path (safe_subpath),
URL parsing (go_url), error wrapping with a prefix (GoWrapped), a built-in MIME
table and content sniffing (go_mime), durations (GoDuration, go_parse_duration,
go_format_duration), the flag parser the launcher uses (go_flag) and the wording of
JSON type-mismatch errors (json_kind, json_expected_found).
Re-exports§
pub use go_fmt::go_format_float_g;pub use go_fmt::go_format_float_v;pub use go_fmt::go_query_escape;pub use go_fmt::go_sprint_value;pub use go_fmt::go_to_lower;pub use go_fmt::go_to_upper;pub use go_fmt::go_type_name;
Modules§
- env
- Environment variable access, injectable for tests.
- go_flag
- A command-line flag parser: a
FlagSetthat reports errors instead of exiting, with string, int, int64, bool, duration, func and bool-func flags. The flag-parsing rules and error texts, the usage message written on failure and theprint_defaultslayout are byte-identical to an ADK launcher’s. - go_mime
- A built-in MIME table (extension to type) and content sniffing (
detect_content_type), shared by the launcher’s web UI and the agentanalytics GCS offloader. - go_url
- URL parsing, escaping and serialization whose accepted inputs and error texts are
byte-identical to an ADK server’s. It covers
parse(acceptance rules and error texts),Url::hostname,Url::port,Url::escaped_path,Url::escaped_fragment,Url::join_pathandUrl::to_go_string, the user, path/raw path, raw query and fragment/raw fragment fields, the path encoding (escape_path,unescape_pathandvalid_encoded_path), andpath_escape,path_unescapeandquery_unescape(query escaping isgo_query_escape). The WHATWG parser of theurlcrate accepts and rejects different inputs, so these checks are separate.
Structs§
- GoDuration
- A duration as signed nanoseconds.
- GoWrapped
- An error that displays
{prefix}: {source}and keepssourceas itssource(), so walks of the error chain find the cause. - Platform
- Explicit replacement for context-carried providers: the clock, UUID source and task runner.
- Safe
Subpath Error - An error of
safe_subpath: itskindand full error text. - Tokio
Task Runner - Default runner: one tokio task per future, held in a
JoinSetso that dropping therunfuture aborts them. A task panic aborts the remaining tasks, waits for them to stop, and is then re-raised on the caller.
Enums§
- Safe
Subpath Error Kind - Which kind of failure a
SafeSubpathErrorreports.
Constants§
- ERR_
NOT_ VALID_ RELATIVE_ PATH - Text of the error for a reference that, read as a string, is not a relative path below the base directory.
- ERR_
SYMLINK_ IN_ RELATIVE_ PATH - Text of the error for a link on the way that leads outside the base directory. A link that stays inside is not an error.
Traits§
- Task
Runner - Runs all tasks and returns after all complete.
- Time
Provider - A source of the current time that tests can replace.
- Uuid
Provider - A source of unique identifier strings that tests can replace.
Functions§
- go_
errno_ text - The text of the OS error
err: the C library’s message for the OS error code with its first letter lowercased (e.g.no such file or directory,permission denied,is a directory); an error without an OS code keeps its own text. - go_
filepath_ is_ local - True when
pathis local: not empty, not absolute and, after cleaning (only when it has a.or..element), neither..nor below../. - go_
filepath_ rel targpathrelative tobasepath, lexically;Rel: can't make <targ> relative to <base>when one is rooted and the other is not, or whenbasepathhas a..element thattargpathdoes not share.- go_
format_ duration - Formats a duration:
"0s"; under one second the largest of ns, µs and ms that keeps an integer part ("1.5µs","500ms"); from one second up[Nh][Nm]S[.fff]swith hours and minutes written once a larger unit is present ("1m0s","1h0m0s"); a leading-for a negative duration. - go_
format_ float_ g - Formats a float in the shortest round-trip
gstyle forbits32 or 64 (any other value is treated as 64; anf32is passed widened):NaN,+Inf,-Inf; otherwise the shortest decimal digits that round-trip at that bit size (for 32, off as f32), in%eform (d.ddde±XX, at least two exponent digits) when the decimal exponent is below -4 or at least 6, otherwise plain decimal. - go_
format_ float_ v - Formats a 64-bit float in
%vstyle, the shortest round-trip form (seego_format_float_g): 1e6 →1e+06, 123456 →123456, 0.00001 →1e-05, -0.0 →-0. - go_
format_ rfc3339_ nano - Formats
tas RFC 3339 with up to nanosecond precision, in its own zone: the fraction’s trailing zeros trimmed (the fraction dropped when zero),Zfor a zero offset,±hh:mmotherwise. Callers that marshal to JSON must check for themselves that the year is within 0..=9999. - go_
parse_ duration - Parses a duration string: a possibly signed sequence of decimal numbers, each with an
optional fraction and a unit suffix (
ns,us/µs/μs,ms,s,m,h), such as"300ms","-1.5h"or"2h45m".Erris the message, e.g.time: invalid duration "x",time: missing unit in duration "1",time: unknown unit "d" in duration "1d". - go_
parse_ rfc3339 - Parses an RFC 3339 timestamp (
YYYY-MM-DDThh:mm:ss, optional fraction, thenZor an offset), reduced to the instant. The accepted forms are: - go_
path_ base - The last element, trailing slashes removed;
.for an empty path,/for a path of slashes. - go_
path_ clean - Cleans a path lexically: drops empty and
.elements, resolves..against the preceding element, keeps leading..elements of a relative path, drops..at the root of a rooted path, and returns.for an empty result (/when rooted). - go_
path_ dir - Everything up to the last
/, cleaned;.without a/. - go_
path_ join - Joins the non-empty elements with
/and cleans the result;""when all are empty. - go_
query_ escape - Escapes
sas a URL query component: every byte except ASCII letters, digits,-,.,_and~becomes%XX(upper-case hex, per UTF-8 byte), and a space becomes+. - go_
sprint_ value - Renders a JSON value as
%vwould print it after decoding into a dynamic value: - go_
to_ lower - Lowercases
scharacter by character withgo_lower_rune, with no final-sigma context. Rust’sstr::to_lowercasediffers for U+0130 and a finalΣ(hereσ, Rustς). - go_
to_ upper - Uppercases
scharacter by character withgo_upper_rune. Rust’sstr::to_uppercasediffers wherever the full mapping has several characters (ß→SS). - go_
type_ name - The type name of a JSON value as a dynamically typed value prints it:
<nil>fornull,bool,float64for every number,string,[]interface {}for an array andmap[string]interface {}for an object. - is_
link_ like - Whether a directory entry may redirect a read somewhere other than where its own name sits in the tree. On Unix that is a symbolic link.
- json_
expected_ found expected <expected>, found <kind of found>, e.g.expected a JSON object, found an array.- json_
kind - The kind of a JSON value as a bare noun:
null,boolean,number,string,arrayorobject. - json_
kind_ article - The kind of a JSON value with its article, as an error names what it found:
null,a boolean,a number,a string,an arrayoran object. - json_
text_ kind_ article json_kind_articlefor raw JSON text, judged by its first non-whitespace byte (the text is assumed to be one valid JSON value; anything unrecognised counts as a number).- safe_
subpath - Resolves
relbelowbaseand checks that the result stays inside it. stays inside it. - tracking_
header - The
user-agent/x-goog-api-clientvalue gadk sends with model and MCP requests:gadk-rust/<crate version> rust/<rustc version>.GADK_RUSTC_VERSIONis set by this crate’sbuild.rs; every workspace crate shares one version, so the value is the same whichever crate asks.