MCPcopy Create free account
hub / github.com/Botloader/botloader / fetch

Method fetch

components/discordoauthwrapper/src/cache.rs:45–58  ·  view source on GitHub ↗

Returns the cached client for the user, creating one through the factory otherwise.

(
        &self,
        user_id: Id<UserMarker>,
        access_token: &str,
    )

Source from the content-addressed store, hash-verified

43 /// Returns the cached client for the user, creating one through the
44 /// factory otherwise.
45 pub fn fetch(
46 &self,
47 user_id: Id<UserMarker>,
48 access_token: &str,
49 ) -> Arc<dyn DiscordOauthClient> {
50 let mut write = self.inner.write().unwrap();
51 if let Some(v) = write.get(&user_id) {
52 return v.clone();
53 }
54
55 let client = (self.factory)(user_id, access_token);
56 write.put(user_id, client.clone());
57 client
58 }
59
60 pub fn del(&self, user_id: Id<UserMarker>) {
61 let mut write = self.inner.write().unwrap();

Callers

nothing calls this directly

Calls 3

putMethod · 0.80
writeMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected