pub enum Message {
Show 13 variants
Handshake {
version: u32,
format: MessageFormat,
compression: Compression,
},
HandshakeAck {
version: u32,
format: MessageFormat,
compression: Compression,
},
SubscribeTiles {
subscription_id: String,
bbox: [f64; 4],
zoom_range: Range<u8>,
tile_size: Option<u32>,
},
SubscribeFeatures {
subscription_id: String,
bbox: Option<[f64; 4]>,
filters: Option<Vec<(String, String)>>,
layer: Option<String>,
},
SubscribeEvents {
subscription_id: String,
event_types: Vec<EventType>,
},
Unsubscribe {
subscription_id: String,
},
TileData {
subscription_id: String,
tile: (u32, u32, u8),
data: Vec<u8>,
mime_type: String,
},
FeatureData {
subscription_id: String,
geojson: String,
change_type: ChangeType,
},
Event {
subscription_id: String,
event_type: EventType,
payload: Value,
timestamp: String,
},
Error {
code: String,
message: String,
request_id: Option<String>,
},
Ping {
id: u64,
},
Pong {
id: u64,
},
Ack {
request_id: String,
success: bool,
message: Option<String>,
},
}Expand description
WebSocket message types exchanged between client and server.
Custom serde::Deserialize is implemented to work around the
serde_json/arbitrary_precision issue: when that feature is active,
serde’s internal Content type represents numbers as Map, causing
[f64; 4] arrays to fail deserialization through the normal
#[serde(tag = "type")] machinery. The fix routes JSON through
serde_json::Value (which handles arbitrary_precision natively) and
only uses the derived tagged-enum path for non-JSON formats such as
MessagePack.
Variants§
Handshake
Handshake message to negotiate protocol
HandshakeAck
Handshake acknowledgement
SubscribeTiles
Subscribe to tile updates
Fields
SubscribeFeatures
Subscribe to feature updates
Fields
SubscribeEvents
Subscribe to events
Fields
Unsubscribe
Unsubscribe from updates
TileData
Tile data response
Fields
FeatureData
Feature data response (GeoJSON)
Fields
change_type: ChangeTypeChange type (added, updated, deleted)
Event
Event notification
Fields
Error
Error message
Fields
Ping
Ping message for keep-alive
Pong
Pong response to ping
Ack
Acknowledgement message
Implementations§
Source§impl Message
Serialization helpers for messages.
impl Message
Serialization helpers for messages.
Sourcepub fn to_msgpack(&self) -> Result<Vec<u8>>
pub fn to_msgpack(&self) -> Result<Vec<u8>>
Serialize message to MessagePack.
Sourcepub fn from_msgpack(data: &[u8]) -> Result<Self>
pub fn from_msgpack(data: &[u8]) -> Result<Self>
Deserialize message from MessagePack.
Sourcepub fn encode(
&self,
format: MessageFormat,
compression: Compression,
) -> Result<Vec<u8>>
pub fn encode( &self, format: MessageFormat, compression: Compression, ) -> Result<Vec<u8>>
Encode message with specified format and compression.
Sourcepub fn decode(
data: &[u8],
format: MessageFormat,
compression: Compression,
) -> Result<Self>
pub fn decode( data: &[u8], format: MessageFormat, compression: Compression, ) -> Result<Self>
Decode message with specified format and compression.