Struct Artifact
#[non_exhaustive]pub struct Artifact {
pub id: Option<String>,
pub name: String,
pub mime_type: Option<String>,
pub data: Value,
pub file: Option<ArtifactFile>,
}Expand description
A named piece of output produced while a run works (a file, a report, a structured result). A2A maps these to task artifacts.
Two forms. A JSON artifact has data (a string becomes a text part, anything else a data
part). A file artifact (Artifact::file) has file, and its media type is
mime_type; its data is null. The A2A server serves a file as a raw part with the media
type and the filename, which any A2A client reads as a file. Artifacts journaled before the
file form existed have no file and read as they did.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: Option<String>The artifact’s identity within the run, when it has one: a later artifact of the run with
the same id replaces it, whichever tool made it, in place (it keeps its position) instead of
being added after it, so a thing that changes while a run works (a plan, a surface) is one
artifact, not one per change. None (artifacts journaled before ids existed, and every
artifact that is only ever made once) is not replaced by anything. Files have no id: a
file artifact is content-addressed (ADR 0012),
so with_id leaves a file without one, and the run never replaces a file nor
replaces anything with a file (an id on a file is dropped, both are kept).
name: StringArtifact name.
mime_type: Option<String>Media type of data (or of the file), if known.
data: ValueThe content of a JSON artifact; null for a file.
file: Option<ArtifactFile>The file, for a file artifact.
Implementations§
§impl Artifact
impl Artifact
pub fn new(
name: impl Into<String>,
mime_type: Option<String>,
data: Value,
) -> Artifact
pub fn new( name: impl Into<String>, mime_type: Option<String>, data: Value, ) -> Artifact
A JSON artifact: data with its media type, if it has one.
pub fn with_id(self, id: impl Into<String>) -> Artifact
pub fn with_id(self, id: impl Into<String>) -> Artifact
Keep this artifact under id: see id. A file artifact stays without one.
pub fn file(
name: impl Into<String>,
media_type: impl Into<String>,
filename: impl Into<String>,
bytes: Vec<u8>,
) -> Result<Artifact, ArtifactFileError>
pub fn file( name: impl Into<String>, media_type: impl Into<String>, filename: impl Into<String>, bytes: Vec<u8>, ) -> Result<Artifact, ArtifactFileError>
A file artifact: bytes, saved as filename, of media_type.
§Errors
[ArtifactFileError]: the file is over [MAX_ARTIFACT_FILE_BYTES], the filename is not a name,
or the media type is not type/subtype.
pub fn upload_ref(
name: impl Into<String>,
media_type: impl Into<String>,
filename: impl Into<String>,
upload_id: impl Into<String>,
) -> Result<Artifact, ArtifactFileError>
pub fn upload_ref( name: impl Into<String>, media_type: impl Into<String>, filename: impl Into<String>, upload_id: impl Into<String>, ) -> Result<Artifact, ArtifactFileError>
A file that was sent by reference (uploads/v1): the bytes went straight to the
bucket, and the artifact names the upload_id the orchestrator issued for them. It holds
no bytes, here or in the journal, and is a JSON artifact whose media type is
[UPLOAD_REF_MEDIA_TYPE] and whose data is {filename, mediaType, uploadId}: the A2A
server serves it as the contract’s data part (see [upload_ref_of]).
§Errors
[ArtifactFileError]: the filename is not a name, the media type is not type/subtype,
or the id is empty or over [MAX_UPLOAD_ID_BYTES].
pub fn file_sha256(&self) -> Option<String>
pub fn file_sha256(&self) -> Option<String>
The SHA-256 of the file’s bytes, as 64 lower-case hexadecimal digits: the name the person’s
screen keeps the file under, and what a form’s picture of it (ask_user’s image.sha256)
refers to. None for a JSON artifact.
§impl Artifact
impl Artifact
What a tool tells the model it shared, in place of the bytes: Shared report.pdf (84.0 KiB, application/pdf). for a file artifact; for an image, also how to use it, by the file’s name
inline in the answer (what the person’s screen resolves an image’s source against, never a
path) and by its SHA-256 as the picture of an ask_user option and in a show Image
block:
Shared chart.png (1.5 KiB, image/png). To show it in your answer, write
. To use it as the picture of an `ask_user` option, pass image
{sha256: "<64 hex digits>", alt}. In a `show` block, an `Image` names it:
{component: "Image", artifact: "<64 hex digits>", alt}.Every source of a shared file says it the same way: the coder’s share_file, a server of an
mcp.json with files: true and a remote subagent with files: true. A JSON artifact is
Shared <name>.
Trait Implementations§
§impl<'de> Deserialize<'de> for Artifact
impl<'de> Deserialize<'de> for Artifact
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Artifact, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Artifact, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for Artifact
impl Serialize for Artifact
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Artifact
Auto Trait Implementations§
impl Freeze for Artifact
impl RefUnwindSafe for Artifact
impl Send for Artifact
impl Sync for Artifact
impl Unpin for Artifact
impl UnsafeUnpin for Artifact
impl UnwindSafe for Artifact
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].