5 releases
0.1.4 | Jul 18, 2024 |
---|---|
0.1.3 | Jul 14, 2024 |
0.1.2 | Jul 14, 2024 |
0.1.1 | Jul 14, 2024 |
0.1.0 | Jul 13, 2024 |
#1527 in Network programming
180 downloads per month
17KB
334 lines
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.
Dependencies
~0.9–1.5MB
~26K SLoC