MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / response

Method response

src/net/http.rs:85–112  ·  view source on GitHub ↗

Check for a completed response. - `None`: still pending - `Some(Ok(resp))`: completed successfully (`Arc `) - `Some(Err(e))`: request failed

(&self)

Source from the content-addressed store, hash-verified

83 /// - `Some(Ok(resp))`: completed successfully (`Arc<Response>`)
84 /// - `Some(Err(e))`: request failed
85 pub fn response(&self) -> Option<Result<Arc<Response>, String>> {
86 let mut mgr = super::NET_MANAGER.lock().unwrap();
87 let entry = mgr.http_requests.get_mut(&self.id)?;
88 entry.frames_not_accessed = 0;
89
90 // Try to transition Pending → Done/Error
91 match &mut entry.state {
92 HttpRequestState::Pending(pending) => {
93 if let Some(result) = pending.try_recv() {
94 match result {
95 Ok(resp) => {
96 entry.state = HttpRequestState::Done(Arc::new(resp));
97 }
98 Err(e) => {
99 entry.state = HttpRequestState::Error(e);
100 }
101 }
102 }
103 }
104 _ => {}
105 }
106
107 match &entry.state {
108 HttpRequestState::Pending(_) => None,
109 HttpRequestState::Done(resp) => Some(Ok(Arc::clone(resp))),
110 HttpRequestState::Error(e) => Some(Err(e.clone())),
111 }
112 }
113
114 /// Cancel and remove a pending request. Consumes the handle.
115 pub fn cancel(self) {

Callers

nothing calls this directly

Calls 2

cloneMethod · 0.80
try_recvMethod · 0.45

Tested by

no test coverage detected