1 //! Error types 2 3 use std::fmt; 4 5 /// An error returned by [`LoadShed`] when the underlying service 6 /// is not ready to handle any requests at the time of being 7 /// called. 8 /// 9 /// [`LoadShed`]: crate::load_shed::LoadShed 10 #[derive(Default)] 11 pub struct Overloaded { 12 _p: (), 13 } 14 15 impl Overloaded { 16 /// Construct a new overloaded error new() -> Self17 pub fn new() -> Self { 18 Overloaded { _p: () } 19 } 20 } 21 22 impl fmt::Debug for Overloaded { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result23 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 24 f.write_str("Overloaded") 25 } 26 } 27 28 impl fmt::Display for Overloaded { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result29 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 30 f.write_str("service overloaded") 31 } 32 } 33 34 impl std::error::Error for Overloaded {} 35