Crate memcached_network_types
source ·Expand description
memcached-network-types
Provides types for memcached protocol entities used for sending requests and responses over the network.
§Usage
memcached-network-types
is a nostd
library crate. You may include it in your Cargo.toml
as follows:
[dependencies]
memcached-network-types = "0.1.4"
Refer to latest git API Documentation for more details.
§Example
use memcached_network_types::binary::*;
let req_get_packet_header = ReqPacketHeader {
magic_byte: ReqMagicByte::ReqPacket,
opcode: Opcode::Get,
key_length: 0.into(),
extras_length: 0,
data_type: DataType::RawBytes,
vbucket: 0.into(),
total_body_length: 0.into(),
opaque: [0; 4],
cas: [0; 8],
};
let bytes = req_get_packet_header.as_bytes();
let req_get_packet_header_parsed = ReqPacketHeader::ref_from(bytes).unwrap();
assert!(&req_get_packet_header == req_get_packet_header_parsed);
let req_get_packet_header_parsed =
ReqPacketHeader::ref_req_packet_header_with_possible_opcode_from(bytes, &[Opcode::Get])
.unwrap();
assert!(&req_get_packet_header == req_get_packet_header_parsed);
const GET_OPCODE: u8 = Opcode::Get as u8;
let req_get_packet_header_parsed = unsafe {
ReqPacketHeader::ref_req_packet_header_with_opcode_from::<GET_OPCODE>(bytes).unwrap()
};
assert!(&req_get_packet_header == req_get_packet_header_parsed);
let req_get_packet_header_parsed =
ReqPacketHeader::ref_req_packet_header_with_get_opcode_from(bytes).unwrap();
assert!(&req_get_packet_header == req_get_packet_header_parsed);
§License
This repository is licensed under the MIT License. See LICENSE for more details.
Modules§
- Provides types pertaining to Memcached binary protocol.
- Contains types related to memcached UDP protocol.
Macros§
- Creates an enum with integer variants.
- Creates constants from integer_enum variants.