Files
go-trustlog/api/model/validation.go
ryan d313449c5c refactor: 重构trustlog-sdk目录结构到trustlog/go-trustlog
- 将所有trustlog-sdk文件移动到trustlog/go-trustlog/目录
- 更新README中所有import路径从trustlog-sdk改为go-trustlog
- 更新cookiecutter配置文件中的项目名称
- 更新根目录.lefthook.yml以引用新位置的配置
- 添加go.sum文件到版本控制
- 删除过时的示例文件

这次重构与trustlog-server保持一致的目录结构,
为未来支持多语言SDK(Python、Java等)预留空间。
2025-12-22 13:37:57 +08:00

33 lines
975 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
// Validation status codes.
const (
ValidationCodeProcessing = 100 // 处理中
ValidationCodeCompleted = 200 // 完成
ValidationCodeFailed = 500 // 失败
)
// ValidationResult 包装取证的流式响应结果.
type ValidationResult struct {
Code int32 // 状态码100处理中200完成500失败
Msg string // 消息描述
Progress string // 当前进度(比如 "50%"
Data *Operation // 最终完成时返回的操作数据,过程中可为空
Proof *Proof // 取证证明(仅在完成时返回)
}
// IsProcessing 判断是否正在处理中.
func (v *ValidationResult) IsProcessing() bool {
return v.Code == ValidationCodeProcessing
}
// IsCompleted 判断是否已完成.
func (v *ValidationResult) IsCompleted() bool {
return v.Code == ValidationCodeCompleted
}
// IsFailed 判断是否失败.
func (v *ValidationResult) IsFailed() bool {
return v.Code >= ValidationCodeFailed
}