#[non_exhaustive]pub enum Error {
Full,
Invalid(&'static str),
CapacityMismatch,
PublisherLimit,
Exhausted,
Corrupt,
Io(Error),
}Expand description
Queue failures; full queues are retryable, while corruption requires a fresh queue.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Full
The queue has insufficient space, or recovery temporarily closed admission.
Invalid(&'static str)
Invalid queue configuration or message length.
CapacityMismatch
An existing queue has a different capacity.
PublisherLimit
All publisher registrations are occupied.
Exhausted
A lifetime counter cannot advance without overflowing.
Corrupt
The shared queue contains an invalid record or registration.
Io(Error)
An operating system operation failed.
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_full(&self) -> bool
pub fn is_full(&self) -> bool
Whether space or recovery admission is temporarily unavailable.
Examples found in repository?
examples/interop.rs (line 46)
14fn main() {
15 let args = std::env::args().collect::<Vec<_>>();
16 let options = Options::new(
17 &args[2],
18 std::env::var("INTEROP_CAPACITY")
19 .map(|v| v.parse().unwrap())
20 .unwrap_or(4096),
21 )
22 .with_path(&args[3]);
23 let count = args[4].parse::<usize>().unwrap();
24 if args[1].starts_with("hold-") {
25 let _publisher;
26 let _subscriber;
27 if args[1] == "hold-publisher" {
28 _publisher = Publisher::open(&options).unwrap();
29 } else {
30 _subscriber = Subscriber::open(&options).unwrap();
31 }
32 println!("READY");
33 io::stdout().flush().unwrap();
34 io::stdin().read_line(&mut String::new()).unwrap();
35 } else if args[1] == "publish" {
36 let publisher = Publisher::open(&options).unwrap();
37 let start = args.get(5).map_or(0, |s| s.parse::<usize>().unwrap());
38 if args.len() > 5 {
39 println!("READY");
40 io::stdout().flush().unwrap();
41 io::stdin().read_line(&mut String::new()).unwrap();
42 }
43 for i in start..start + count {
44 let data = message(i);
45 while let Err(error) = publisher.try_send(&data) {
46 assert!(error.is_full(), "{error}");
47 std::thread::yield_now();
48 }
49 }
50 } else {
51 let subscriber = Subscriber::open(&options).unwrap();
52 println!("READY");
53 if args[1] == "collect" {
54 loop {
55 let data = subscriber
56 .recv_timeout(Duration::from_secs(30))
57 .unwrap()
58 .unwrap();
59 if data.is_empty() {
60 break;
61 }
62 let id = u64::from_le_bytes(data[..8].try_into().unwrap()) as usize;
63 assert_eq!(data, message(id));
64 println!("{id}");
65 }
66 return;
67 }
68 for i in 0..count {
69 assert_eq!(
70 subscriber
71 .recv_timeout(Duration::from_secs(30))
72 .unwrap()
73 .unwrap(),
74 message(i)
75 );
76 }
77 }
78}Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more