CMDC.Backend.Results.FileData (cmdc v0.4.0)

Copy Markdown View Source

文件数据 typed map(对标 deepagents FileData TypedDict)。

格式版本

  • v1(legacy):content[binary](按 \n 分割的行列表),无 encoding 字段
  • v2(current):contentbinary,加 encoding 字段("utf-8""base64"

Backend 接受两种格式作为输入,输出推荐 v2。

Summary

Functions

构建 v2 格式文件数据。

返回 v1(legacy)格式(lines list)。

字符串内容(处理 v1/v2 两种格式)。

从 v1 (lines) 转 v2 (string);幂等。

Types

t()

@type t() :: %{
  :content => String.t() | [String.t()],
  optional(:encoding) => String.t(),
  optional(:created_at) => String.t(),
  optional(:modified_at) => String.t()
}

Functions

new(content, opts \\ [])

@spec new(
  String.t(),
  keyword()
) :: t()

构建 v2 格式文件数据。

to_legacy(file_data)

@spec to_legacy(t()) :: %{content: [String.t()]}

返回 v1(legacy)格式(lines list)。

to_string(map)

@spec to_string(t()) :: String.t()

字符串内容(处理 v1/v2 两种格式)。

to_v2(file_data)

@spec to_v2(t()) :: t()

从 v1 (lines) 转 v2 (string);幂等。