Map a [`WireVersionError`] to a `ClusterError::Transport` with the QUIC connection closed. Helper shared by callers that have already negotiated but encounter a per-frame version mismatch.
(conn: &quinn::Connection, e: WireVersionError)
| 160 | /// connection closed. Helper shared by callers that have already negotiated |
| 161 | /// but encounter a per-frame version mismatch. |
| 162 | pub fn close_on_version_error(conn: &quinn::Connection, e: WireVersionError) -> ClusterError { |
| 163 | let reason = e.to_string(); |
| 164 | let reason_bytes = reason.as_bytes(); |
| 165 | conn.close( |
| 166 | quinn::VarInt::from_u32(0x01), |
| 167 | &reason_bytes[..reason_bytes.len().min(100)], |
| 168 | ); |
| 169 | ClusterError::Transport { |
| 170 | detail: format!("wire version mismatch: {e}"), |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | #[cfg(test)] |
| 175 | mod tests { |