@@ -55,6 +55,7 @@ use std::num::NonZeroUsize;
5555use std:: task:: { Context , Poll } ;
5656use std:: vec;
5757use std:: { borrow:: Cow , time:: Duration } ;
58+ use thiserror:: Error ;
5859
5960pub use crate :: query:: QueryStats ;
6061
@@ -2583,14 +2584,16 @@ pub struct PutRecordOk {
25832584}
25842585
25852586/// The error result of [`Kademlia::put_record`].
2586- #[ derive( Debug , Clone ) ]
2587+ #[ derive( Debug , Clone , Error ) ]
25872588pub enum PutRecordError {
2589+ #[ error( "the quorum failed; needed {quorum} peers" ) ]
25882590 QuorumFailed {
25892591 key : record:: Key ,
25902592 /// [`PeerId`]s of the peers the record was successfully stored on.
25912593 success : Vec < PeerId > ,
25922594 quorum : NonZeroUsize ,
25932595 } ,
2596+ #[ error( "the request timed out" ) ]
25942597 Timeout {
25952598 key : record:: Key ,
25962599 /// [`PeerId`]s of the peers the record was successfully stored on.
@@ -2629,8 +2632,9 @@ pub struct BootstrapOk {
26292632}
26302633
26312634/// The error result of [`Kademlia::bootstrap`].
2632- #[ derive( Debug , Clone ) ]
2635+ #[ derive( Debug , Clone , Error ) ]
26332636pub enum BootstrapError {
2637+ #[ error( "the request timed out" ) ]
26342638 Timeout {
26352639 peer : PeerId ,
26362640 num_remaining : Option < u32 > ,
@@ -2648,8 +2652,9 @@ pub struct GetClosestPeersOk {
26482652}
26492653
26502654/// The error result of [`Kademlia::get_closest_peers`].
2651- #[ derive( Debug , Clone ) ]
2655+ #[ derive( Debug , Clone , Error ) ]
26522656pub enum GetClosestPeersError {
2657+ #[ error( "the request timed out" ) ]
26532658 Timeout { key : Vec < u8 > , peers : Vec < PeerId > } ,
26542659}
26552660
@@ -2682,8 +2687,9 @@ pub struct GetProvidersOk {
26822687}
26832688
26842689/// The error result of [`Kademlia::get_providers`].
2685- #[ derive( Debug , Clone ) ]
2690+ #[ derive( Debug , Clone , Error ) ]
26862691pub enum GetProvidersError {
2692+ #[ error( "the request timed out" ) ]
26872693 Timeout {
26882694 key : record:: Key ,
26892695 providers : HashSet < PeerId > ,
@@ -2718,9 +2724,9 @@ pub struct AddProviderOk {
27182724}
27192725
27202726/// The possible errors when publishing a provider record.
2721- #[ derive( Debug , Clone ) ]
2727+ #[ derive( Debug , Clone , Error ) ]
27222728pub enum AddProviderError {
2723- /// The query timed out.
2729+ # [ error ( "the request timed out" ) ]
27242730 Timeout { key : record:: Key } ,
27252731}
27262732
0 commit comments