Skip to main content

Message

Enum Message 

Source
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

Fields

§version: u32

Protocol version

§format: MessageFormat

Preferred message format

§compression: Compression

Preferred compression

§

HandshakeAck

Handshake acknowledgement

Fields

§version: u32

Accepted protocol version

§format: MessageFormat

Accepted message format

§compression: Compression

Accepted compression

§

SubscribeTiles

Subscribe to tile updates

Fields

§subscription_id: String

Subscription ID

§bbox: [f64; 4]

Bounding box [min_x, min_y, max_x, max_y]

§zoom_range: Range<u8>

Zoom level range

§tile_size: Option<u32>

Tile size (default 256)

§

SubscribeFeatures

Subscribe to feature updates

Fields

§subscription_id: String

Subscription ID

§bbox: Option<[f64; 4]>

Bounding box filter (optional)

§filters: Option<Vec<(String, String)>>

Attribute filters (key-value pairs)

§layer: Option<String>

Layer name filter

§

SubscribeEvents

Subscribe to events

Fields

§subscription_id: String

Subscription ID

§event_types: Vec<EventType>

Event types to subscribe to

§

Unsubscribe

Unsubscribe from updates

Fields

§subscription_id: String

Subscription ID to cancel

§

TileData

Tile data response

Fields

§subscription_id: String

Subscription ID

§tile: (u32, u32, u8)

Tile coordinates (x, y, zoom)

§data: Vec<u8>

Tile data (MVT, PNG, etc.)

§mime_type: String

MIME type

§

FeatureData

Feature data response (GeoJSON)

Fields

§subscription_id: String

Subscription ID

§geojson: String

GeoJSON feature or feature collection

§change_type: ChangeType

Change type (added, updated, deleted)

§

Event

Event notification

Fields

§subscription_id: String

Subscription ID

§event_type: EventType

Event type

§payload: Value

Event payload

§timestamp: String

Event timestamp (RFC3339)

§

Error

Error message

Fields

§code: String

Error code

§message: String

Error message

§request_id: Option<String>

Request ID that caused the error (if applicable)

§

Ping

Ping message for keep-alive

Fields

§id: u64

Ping ID

§

Pong

Pong response to ping

Fields

§id: u64

Ping ID being acknowledged

§

Ack

Acknowledgement message

Fields

§request_id: String

Request ID being acknowledged

§success: bool

Success status

§message: Option<String>

Optional message

Implementations§

Source§

impl Message

Serialization helpers for messages.

Source

pub fn to_json(&self) -> Result<String>

Serialize message to JSON.

Source

pub fn from_json(s: &str) -> Result<Self>

Deserialize message from JSON.

Source

pub fn to_msgpack(&self) -> Result<Vec<u8>>

Serialize message to MessagePack.

Source

pub fn from_msgpack(data: &[u8]) -> Result<Self>

Deserialize message from MessagePack.

Source

pub fn compress(data: &[u8], level: i32) -> Result<Vec<u8>>

Compress data using zstd.

Source

pub fn decompress(data: &[u8]) -> Result<Vec<u8>>

Decompress zstd data.

Source

pub fn encode( &self, format: MessageFormat, compression: Compression, ) -> Result<Vec<u8>>

Encode message with specified format and compression.

Source

pub fn decode( data: &[u8], format: MessageFormat, compression: Compression, ) -> Result<Self>

Decode message with specified format and compression.

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Message

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Message

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Message

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Message

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,