ClaudeCode.Content.Text (ClaudeCode v0.1.0)

View Source

Represents a text content block within a Claude message.

Text blocks contain plain text content that represents Claude's response or user input.

Summary

Functions

Creates a new Text content block from JSON data.

Type guard to check if a value is a Text content block.

Types

t()

@type t() :: %ClaudeCode.Content.Text{text: String.t(), type: :text}

Functions

new(data)

@spec new(map()) :: {:ok, t()} | {:error, atom()}

Creates a new Text content block from JSON data.

Examples

iex> Text.new(%{"type" => "text", "text" => "Hello!"})
{:ok, %Text{type: :text, text: "Hello!"}}

iex> Text.new(%{"type" => "tool_use", "text" => "Hi"})
{:error, :invalid_content_type}

text_content?(arg1)

@spec text_content?(any()) :: boolean()

Type guard to check if a value is a Text content block.