| 32 | } |
| 33 | |
| 34 | Shared<snap::valdi_core::Cancelable> AssetBytesStore::downloadItem( |
| 35 | const StringBox& url, Function<void(const Result<BytesView>&)> completion) { |
| 36 | Result<BytesView> result; |
| 37 | { |
| 38 | std::lock_guard<Mutex> lock(_mutex); |
| 39 | const auto& it = _bytesByUrl.find(url); |
| 40 | if (it != _bytesByUrl.end()) { |
| 41 | result = Result<BytesView>(it->second); |
| 42 | } else { |
| 43 | result = Result<BytesView>(Error("Did not find associated bytes with url")); |
| 44 | } |
| 45 | } |
| 46 | completion(result); |
| 47 | return nullptr; |
| 48 | } |
| 49 | |
| 50 | StringBox AssetBytesStore::getUrlScheme() { |
| 51 | const auto& prefix = getAssetBytesStoreUrlPrefix(); |