MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / get_state

Method get_state

atomic-remote/src/http/queries.rs:29–67  ·  view source on GitHub ↗

Get the current state of a view. # Arguments `view` - The name of the view to query. # Returns The current state of the view, or `StateResponse::Empty` if the view is empty.

(&self, view: &str)

Source from the content-addressed store, hash-verified

27 /// The current state of the view, or `StateResponse::Empty` if the
28 /// view is empty.
29 pub async fn get_state(&self, view: &str) -> RemoteResult<StateResponse> {
30 let url = format!("{}?view={}&state=", self.base_url, view);
31 debug!("GET state: {}", url);
32
33 let response = self
34 .client
35 .get(&url)
36 .send()
37 .await
38 .map_err(|e| RemoteError::connection_failed(&url, e))?;
39
40 crate::check_min_version_header(response.headers());
41 let status = response.status();
42 trace!("GET state response status: {}", status);
43
44 match status {
45 StatusCode::OK => {
46 let text = response
47 .text()
48 .await
49 .map_err(|e| RemoteError::connection_failed(&url, e))?;
50
51 trace!("GET state response body: {:?}", text);
52
53 StateResponse::parse(&text).map_err(|e| {
54 RemoteError::protocol(format!("Failed to parse state response: {}", e))
55 })
56 }
57 StatusCode::NOT_FOUND => Err(RemoteError::view_not_found(view)),
58 StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => {
59 let msg = response.text().await.unwrap_or_default();
60 Err(RemoteError::auth_failed(&url, msg))
61 }
62 _ => {
63 let msg = response.text().await.unwrap_or_default();
64 Err(RemoteError::http(status.as_u16(), msg))
65 }
66 }
67 }
68
69 /// Get the changelist for a view starting from a position.
70 ///

Callers

nothing calls this directly

Calls 4

check_min_version_headerFunction · 0.85
textMethod · 0.80
getMethod · 0.65
statusMethod · 0.45

Tested by

no test coverage detected