| 380 | } |
| 381 | |
| 382 | int ReadBlob(skr_binary_reader_t* reader, skr::BlobId& out_id) |
| 383 | { |
| 384 | // TODO: blob 应该特别处理 |
| 385 | uint64_t size; |
| 386 | int ret = skr::binary::Read(reader, size); |
| 387 | if (ret != 0) |
| 388 | { |
| 389 | SKR_LOG_FATAL(u8"failed to read blob size! ret code: %d", ret); |
| 390 | return ret; |
| 391 | } |
| 392 | auto blob = skr::IBlob::Create(nullptr, size, false); |
| 393 | if (blob == nullptr) |
| 394 | { |
| 395 | SKR_LOG_FATAL(u8"failed to create blob! ret code: %d", ret); |
| 396 | return ret; |
| 397 | } |
| 398 | |
| 399 | ret = ReadBytes(reader, blob->get_data(), blob->get_size()); |
| 400 | if (ret != 0) |
| 401 | { |
| 402 | SKR_LOG_FATAL(u8"failed to read blob content! ret code: %d", ret); |
| 403 | return ret; |
| 404 | } |
| 405 | |
| 406 | out_id = blob; |
| 407 | return ret; |
| 408 | } |
| 409 | int ReadTrait<skr::IBlob*>::Read(skr_binary_reader_t* reader, skr::IBlob*& out_blob) |
| 410 | { |
| 411 | skr::BlobId new_blob = nullptr; |