- VertexApiError gains a serde-skipped retry_after field, filled from the
Retry-After header. VertexApiError::retry_delay() prefers RetryInfo and
falls back to it, so a JSON 429 without RetryInfo still exposes the
header delay.
- parse_retry_after rejects anything but ASCII digits; u64::from_str
alone accepted a leading '+'.
- Client tests share mock_client/http_response helpers instead of
repeating the mock server setup in every test.
Error::HttpStatus gains a retry_after field, filled from the response's
Retry-After header (delay-seconds form) before the body is consumed.
Error::retry_delay() now returns it for HttpStatus errors, so a 429 or
503 with a non-Vertex body still exposes the server's retry hint.
Closes#21
- Drop the unreachable checked_mul in parse_duration; a fraction of at
most 9 digits scaled to nanoseconds always fits in a u32.
- Share a vertex_error test helper in error.rs instead of building
VertexApiError inline.
- Bump version to 0.2.0 for the breaking VertexApiError.details change.
VertexApiError.details is now Option<Vec<serde_json::Value>> so that
unknown google.rpc.* detail types (e.g. RetryInfo, QuotaFailure) no
longer break deserialization and fall back to Error::HttpStatus. The
unused ErrorType, ErrorInfoMetadata, FieldViolation and Link types are
removed.
Add VertexApiError::retry_delay() which parses the protobuf duration in a
google.rpc.RetryInfo entry, and Error::retry_delay() which delegates to it.
Closes#19
The Gitea runner image doesn't include Rust, so every job failed at
'cargo: command not found'. Install the stable toolchain, cache the
build, and run cargo fmt --check and clippy alongside the tests.
decode returned None after each non-empty line, which makes FramedRead wait for more bytes before decoding again, so each event was held until the next network read. Loop until an event is complete or the buffer has no full line left.
Check response.status() before building the SSE event stream. On non-success
status, parse the response body as GenerateContentResponseError when
possible (returning Error::VertexError), and fall back to Error::HttpStatus
with the status code and raw text. Adds tests for HTTP 400 Vertex error,
non-JSON HTTP 500 error, and successful 200 SSE streaming.
FunctionDeclaration.parameters becomes Option<Value>, and the new
parameters_json_schema field sends the schema as JSON Schema. Vertex
rejects many JSON Schema keywords in parameters ($schema, $ref/$defs,
const, type arrays) but accepts them in parametersJsonSchema. Both
fields are skipped when None, since Vertex rejects a declaration that
sets both.
Calls a function, returns a solid-color PNG as functionResponse.parts
inlineData, and checks that the model names the color. COLOR picks the
color; otherwise it is picked by time.
Adds an optional parts field to FunctionResponseData, serialized as
functionResponse.parts with inlineData, so function responses can carry
images. It is omitted when empty, so existing requests are unchanged.
- Introducues generate_content_stream that returns a Tokio Steam instead
of a Queue. This allows using the standard stream APIs from
tokio-streams.
- Replace future-utils with tokio-streams, mainly due to better
ergonomics for using the filter_map stream combinator.
- The API doesn't always return `probabilityScore` and
`severityScore` for a safety rating, causing the parsing to fail
- This commit makes those fields optional to fix that.