name = "locks"
version = "0.1.0"
dependencies = [
+ "thiserror",
"ticket_fields",
]
name = "patch"
version = "0.1.0"
dependencies = [
+ "thiserror",
"ticket_fields",
]
name = "rwlock"
version = "0.1.0"
dependencies = [
+ "thiserror",
"ticket_fields",
]
[[package]]
name = "thiserror"
-version = "1.0.59"
+version = "1.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa"
+checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.59"
+version = "1.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66"
+checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524"
dependencies = [
"proc-macro2",
"quote",
[dependencies]
ticket_fields = { path = "../../../helpers/ticket_fields" }
+thiserror = "1.0.59"
-use std::sync::mpsc::{sync_channel, Receiver, SyncSender, TrySendError};
+use std::sync::mpsc::{sync_channel, Receiver, SyncSender};
// TODO: Implement the patching functionality.
use crate::data::{Ticket, TicketDraft, TicketPatch};
}
impl TicketStoreClient {
- pub fn insert(&self, draft: TicketDraft) -> Result<TicketId, TrySendError<Command>> {
+ pub fn insert(&self, draft: TicketDraft) -> Result<TicketId, OverloadedError> {
let (response_sender, response_receiver) = sync_channel(1);
- self.sender.try_send(Command::Insert {
- draft,
- response_channel: response_sender,
- })?;
+ self.sender
+ .try_send(Command::Insert {
+ draft,
+ response_channel: response_sender,
+ })
+ .map_err(|_| OverloadedError)?;
Ok(response_receiver.recv().unwrap())
}
- pub fn get(&self, id: TicketId) -> Result<Option<Ticket>, TrySendError<Command>> {
+ pub fn get(&self, id: TicketId) -> Result<Option<Ticket>, OverloadedError> {
let (response_sender, response_receiver) = sync_channel(1);
- self.sender.try_send(Command::Get {
- id,
- response_channel: response_sender,
- })?;
+ self.sender
+ .try_send(Command::Get {
+ id,
+ response_channel: response_sender,
+ })
+ .map_err(|_| OverloadedError)?;
Ok(response_receiver.recv().unwrap())
}
- pub fn update(&self, ticket_patch: TicketPatch) -> Result<(), TrySendError<Command>> {}
+ pub fn update(&self, ticket_patch: TicketPatch) -> Result<(), OverloadedError> {}
}
+#[derive(Debug, thiserror::Error)]
+#[error("The store is overloaded")]
+pub struct OverloadedError;
+
pub fn launch(capacity: usize) -> TicketStoreClient {
let (sender, receiver) = sync_channel(capacity);
std::thread::spawn(move || server(receiver));
[dependencies]
ticket_fields = { path = "../../../helpers/ticket_fields" }
+thiserror = "1.0.60"
}
impl TicketStoreClient {
- pub fn insert(&self, draft: TicketDraft) -> Result<TicketId, TrySendError<Command>> {
+ pub fn insert(&self, draft: TicketDraft) -> Result<TicketId, OverloadedError> {
let (response_sender, response_receiver) = sync_channel(1);
- self.sender.try_send(Command::Insert {
- draft,
- response_channel: response_sender,
- })?;
+ self.sender
+ .try_send(Command::Insert {
+ draft,
+ response_channel: response_sender,
+ })
+ .map_err(|_| OverloadedError)?;
Ok(response_receiver.recv().unwrap())
}
- pub fn get(&self, id: TicketId) -> Result<Option<Arc<Mutex<Ticket>>>, TrySendError<Command>> {
+ pub fn get(&self, id: TicketId) -> Result<Option<Arc<Mutex<Ticket>>>, OverloadedError> {
let (response_sender, response_receiver) = sync_channel(1);
- self.sender.try_send(Command::Get {
- id,
- response_channel: response_sender,
- })?;
+ self.sender
+ .try_send(Command::Get {
+ id,
+ response_channel: response_sender,
+ })
+ .map_err(|_| OverloadedError)?;
Ok(response_receiver.recv().unwrap())
}
}
+#[derive(Debug, thiserror::Error)]
+#[error("The store is overloaded")]
+pub struct OverloadedError;
+
pub fn launch(capacity: usize) -> TicketStoreClient {
let (sender, receiver) = sync_channel(capacity);
std::thread::spawn(move || server(receiver));
[dependencies]
ticket_fields = { path = "../../../helpers/ticket_fields" }
+thiserror = "1.0.60"
}
impl TicketStoreClient {
- pub fn insert(&self, draft: TicketDraft) -> Result<TicketId, TrySendError<Command>> {
+ pub fn insert(&self, draft: TicketDraft) -> Result<TicketId, OverloadedError> {
let (response_sender, response_receiver) = sync_channel(1);
- self.sender.try_send(Command::Insert {
- draft,
- response_channel: response_sender,
- })?;
+ self.sender
+ .try_send(Command::Insert {
+ draft,
+ response_channel: response_sender,
+ })
+ .map_err(|_| OverloadedError)?;
Ok(response_receiver.recv().unwrap())
}
- pub fn get(&self, id: TicketId) -> Result<Option<Arc<Mutex<Ticket>>>, TrySendError<Command>> {
+ pub fn get(&self, id: TicketId) -> Result<Option<Arc<Mutex<Ticket>>>, OverloadedError> {
let (response_sender, response_receiver) = sync_channel(1);
- self.sender.try_send(Command::Get {
- id,
- response_channel: response_sender,
- })?;
+ self.sender
+ .try_send(Command::Get {
+ id,
+ response_channel: response_sender,
+ })
+ .map_err(|_| OverloadedError)?;
Ok(response_receiver.recv().unwrap())
}
}
+#[derive(Debug, thiserror::Error)]
+#[error("The store is overloaded")]
+pub struct OverloadedError;
+
pub fn launch(capacity: usize) -> TicketStoreClient {
let (sender, receiver) = sync_channel(capacity);
std::thread::spawn(move || server(receiver));