Crates.io | memcached-network-types |
lib.rs | memcached-network-types |
version | 0.1.4 |
source | src |
created_at | 2024-07-13 07:40:48.108774 |
updated_at | 2024-07-18 16:09:19.255344 |
description | Provides types for memcached protocol entities used for sending requests and responses over the network. |
homepage | |
repository | https://github.com/arindas/memcached-network-types |
max_upload_size | |
id | 1302113 |
size | 18,675 |
memcached-network-types
Provides types for memcached protocol entities used for sending requests and responses over the network.
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.
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);
This repository is licensed under the MIT License. See LICENSE for more details.