mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-04-25 11:02:12 +00:00
#10 Serialize array of records via protobuf
This commit is contained in:
commit
5a8a294f84
@ -1,6 +1,10 @@
|
||||
syntax = "proto3";
|
||||
package dht.pb;
|
||||
|
||||
message Records {
|
||||
repeated Record records = 1;
|
||||
}
|
||||
|
||||
// Record represents a dht record that contains a value
|
||||
// for a key value pair
|
||||
message Record {
|
||||
|
@ -50,6 +50,7 @@ pub use behaviour::{Kademlia, KademliaConfig, KademliaEvent, Quorum};
|
||||
pub use protocol::KadConnectionType;
|
||||
pub use query::QueryId;
|
||||
pub use record::{store, ProviderRecord, Record};
|
||||
pub use dht_proto::{Record as ProtoRecord, Records as ProtoRecords};
|
||||
|
||||
use std::num::NonZeroUsize;
|
||||
|
||||
|
@ -539,7 +539,7 @@ fn proto_to_resp_msg(message: proto::Message) -> Result<KadResponseMsg, io::Erro
|
||||
}
|
||||
}
|
||||
|
||||
fn record_from_proto(record: proto::Record) -> Result<Record, io::Error> {
|
||||
pub fn record_from_proto(record: proto::Record) -> Result<Record, io::Error> {
|
||||
let key = record::Key::from(record.key);
|
||||
let value = record.value;
|
||||
|
||||
@ -562,7 +562,7 @@ fn record_from_proto(record: proto::Record) -> Result<Record, io::Error> {
|
||||
Ok(Record { key, value, publisher, expires })
|
||||
}
|
||||
|
||||
fn record_to_proto(record: Record) -> proto::Record {
|
||||
pub fn record_to_proto(record: Record) -> proto::Record {
|
||||
proto::Record {
|
||||
key: record.key.to_vec(),
|
||||
value: record.value,
|
||||
|
@ -70,7 +70,7 @@ impl From<Multihash> for Key {
|
||||
}
|
||||
|
||||
/// A record stored in the DHT.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
|
||||
pub struct Record {
|
||||
/// Key of the record.
|
||||
pub key: Key,
|
||||
|
Loading…
x
Reference in New Issue
Block a user