MCPcopy Create free account
hub / github.com/Snapchat/Valdi / loadModule

Method loadModule

valdi/src/valdi/runtime/Resources/Remote/RemoteModuleManager.cpp:363–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361}
362
363void RemoteModuleManager::loadModule(const StringBox& moduleName,
364 Function<void(Result<Ref<ValdiModuleArchive>>)> completion) {
365 auto manifest = getRegisteredManifest(moduleName);
366 if (manifest == nullptr) {
367 completion(Error(STRING_FORMAT("Module '{}' doesnt have a downloadable manifest registered", moduleName)));
368 return;
369 }
370
371 auto url = StringCache::getGlobal().makeString(manifest->pb.artifact().url());
372 const auto& sha256Digest = manifest->pb.artifact().sha256digest();
373 auto sha256DigestBytesView =
374 BytesView(manifest, reinterpret_cast<const Byte*>(sha256Digest.data()), sha256Digest.size());
375
376 auto weakThis = weakRef(this);
377 _downloader->enqueue(moduleName.prepend("module-"),
378 url,
379 _moduleTransformer,
380 sha256DigestBytesView,
381 [weakThis, completion = std::move(completion)](auto result, auto /*loadSource*/) {
382 auto strongThis = weakThis.lock();
383 if (strongThis != nullptr) {
384 strongThis->handleModuleLoadCompleted(result, completion);
385 }
386 });
387}
388
389void RemoteModuleManager::setDecompressionDisabled(bool decompressionDisabled) {
390 _moduleTransformer.setDecompressionDisabled(decompressionDisabled);

Callers

nothing calls this directly

Calls 12

getGlobalFunction · 0.85
weakRefFunction · 0.85
makeStringMethod · 0.80
urlMethod · 0.80
prependMethod · 0.65
ErrorInterface · 0.50
BytesViewClass · 0.50
dataMethod · 0.45
sizeMethod · 0.45
enqueueMethod · 0.45
lockMethod · 0.45

Tested by

no test coverage detected