Struct bililive_core::packet::Packet[][src]

pub struct Packet { /* fields omitted */ }
Expand description

Bililive packet.

Packet can be used to encode/parse raw bilibili live packets, and extract information from it.

Implementations

Set the protocol version.

Set the operation.

Set the sequence id. By default it’s 1.

Set the packet body. Packet length will be updated automatically.

Construct a new packet.

To construct a zlib-compressed packet, you should create a JSON/Int32BE packet first, then call Packet::compress to convert it to a zlib one.

Convert a JSON/Int32BE packet to a zlib-compressed one.

Errors

Return errors if compression fails.

Get the packet length.

Get the header length.

Get the sequence id.

Get the operation.

Get the protocol version.

Get bytes of the body.

Try to parse the body by json.

Errors

It may fail if the model is incorrect or it’s not a json packet. You may check the type of the packet by Packet::proto.

Try to parse the body by big endian int32.

Errors

It may fail if it’s not a int packet. You may check the type of the packet by Packet::proto.

Encode the packet into bytes ready to be sent to the server.

Parse the packet received from Bilibili server.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type of value produced by the sink when an error occurs.

Attempts to prepare the Sink to receive a value. Read more

Begin the process of sending a value to the sink. Each call to this function must be preceded by a successful call to poll_ready which returned Poll::Ready(Ok(())). Read more

Flush any remaining output from this sink. Read more

Flush any remaining output and close this sink, if necessary. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.