MCPcopy Create free account
hub / github.com/0x676e67/wreq-python / from_close

Method from_close

src/client/async_impl/response/ws/message.rs:156–166  ·  view source on GitHub ↗
(code: u16, reason: Option<PyBackedStr>)

Source from the content-addressed store, hash-verified

154 #[staticmethod]
155 #[pyo3(signature = (code, reason=None))]
156 pub fn from_close(code: u16, reason: Option<PyBackedStr>) -> Self {
157 let reason = reason
158 .map(Bytes::from_owner)
159 .map(Utf8Bytes::from_bytes_unchecked)
160 .unwrap_or_else(|| wreq::Utf8Bytes::from_static("Goodbye"));
161 let msg = wreq::Message::close(wreq::CloseFrame {
162 code: wreq::CloseCode(code),
163 reason,
164 });
165 Message(msg)
166 }
167
168 fn __str__(&self) -> String {
169 format!("{:?}", self.0)

Callers

nothing calls this directly

Calls 1

MessageClass · 0.85

Tested by

no test coverage detected