Skip to main content

Crate gadk_platform

Crate gadk_platform 

Source
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 FlagSet that 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 the print_defaults layout 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 (except an invalid IPv6 host literal, reported as invalid host: unable to parse IP "…"). It covers parse (acceptance rules and error texts), Url::hostname, Url::port, Url::escaped_path, Url::escaped_fragment, Url::join_path and Url::to_go_string, the user, path/raw path, raw query and fragment/raw fragment fields, the path encoding (escape_path, unescape_path and valid_encoded_path), and path_escape, path_unescape and query_unescape (query escaping is go_query_escape). The WHATWG parser of the url crate 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 keeps source as its source(), so walks of the error chain find the cause.
Platform
Explicit replacement for context-carried providers: the clock, UUID source and task runner.
SafeSubpathError
An error of safe_subpath: its kind and full error text.
TokioTaskRunner
Default runner: one tokio task per future, held in a JoinSet so that dropping the run future aborts them. A task panic aborts the remaining tasks, waits for them to stop, and is then re-raised on the caller.

Enums§

SafeSubpathErrorKind
Which kind of failure a SafeSubpathError reports.

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§

TaskRunner
Runs all tasks and returns after all complete.
TimeProvider
A source of the current time that tests can replace.
UuidProvider
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 path is local: not empty, not absolute and, after cleaning (only when it has a . or .. element), neither .. nor below ../.
go_filepath_rel
targpath relative to basepath, lexically; Rel: can't make <targ> relative to <base> when one is rooted and the other is not, or when basepath has a .. element that targpath does 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]s with 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 g style for bits 32 or 64 (any other value is treated as 64; an f32 is passed widened): NaN, +Inf, -Inf; otherwise the shortest decimal digits that round-trip at that bit size (for 32, of f as f32), in %e form (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 %v style, the shortest round-trip form (see go_format_float_g): 1e6 → 1e+06, 123456 → 123456, 0.00001 → 1e-05, -0.0 → -0.
go_format_rfc3339_nano
Formats t as RFC 3339 with up to nanosecond precision, in its own zone: the fraction’s trailing zeros trimmed (the fraction dropped when zero), Z for a zero offset, ±hh:mm otherwise. 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". Err is the message, e.g. invalid duration "x", missing unit in duration "1", unknown unit "d" in duration "1d".
go_parse_rfc3339
Parses an RFC 3339 timestamp (YYYY-MM-DDThh:mm:ss, optional fraction, then Z or 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 s as 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 %v would print it after decoding into a dynamic value:
go_to_lower
Lowercases s character by character with go_lower_rune, with no final-sigma context. Rust’s str::to_lowercase differs for U+0130 and a final Σ (here σ, Rust ς).
go_to_upper
Uppercases s character by character with go_upper_rune. Rust’s str::to_uppercase differs 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> for null, bool, float64 for every number, string, []interface {} for an array and map[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, array or object.
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 array or an object.
json_text_kind_article
json_kind_article for 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 rel below base and checks that the result stays inside it. stays inside it.
tracking_header
The user-agent / x-goog-api-client value gadk sends with model and MCP requests: gadk-rust/<crate version> rust/<rustc version>. GADK_RUSTC_VERSION is set by this crate’s build.rs; every workspace crate shares one version, so the value is the same whichever crate asks.

Type Aliases§

BoxFuture
An owned dynamically typed Future for use in cases where you can’t statically type your result or need to add some indirection.