mattsse / chromiumoxide

Chrome Devtools Protocol rust API
Apache License 2.0
712 stars 69 forks source link

[Based on #195 but zero-copy] Log ws message on parsing error to Message enum #204

Closed ryo33 closed 4 months ago

ryo33 commented 4 months ago

As the title, this is based on #195, but zero-copy.

Also, it changes from doing serde_json::from_slice(&data.into_data()) to doing serde_json::from_str(&text) of WsMessage::Text(text). Other variants of WsMessage are handled as follows:

MOZGIII commented 4 months ago

Is it safe to ignore the bytes and frames though?

ryo33 commented 4 months ago

Is it safe to ignore the bytes and frames though?

Ignoring Frame is safe because we should not get it when reading a message as https://github.com/snapview/tungstenite-rs/pull/250.

IMO ignoring Bytes is also safe because cdp is a JSON-based protocol and I suppose it uses only the text type of frame.

MOZGIII commented 4 months ago

CDP actually can stream the responses - which would suggest using the advanced websocket capabilities - but I checked and it indeed only uses text with data embedded as base64.

See: