rust-rocket

Compiler says that data cannot be shared between threads safely even though the data is wrapped within a Mutex

社会主义新天地 提交于 2019-12-01 08:55:10
I'm using Rocket which has a State that it passes to the HTTP requests. This struct contains a Mutex<DatastoreInstance> which gives access to a SQLite database and is locked with a mutex to make read and writes safe. pub struct DatastoreInstance { conn: Connection, } When the DatastoreInstance struct looked like this, with only a SQLite connection everything worked fine, but I then also wanted to add a transaction object within this struct: pub struct DatastoreInstance { conn: Connection, events_transaction: Transaction, } This did not compile because the Transaction object needs to reference

How to parse multipart forms using abonander/multipart with Rocket?

让人想犯罪 __ 提交于 2019-11-30 21:03:30
This might be useful for me : I have no idea how you're meant to go about parsing a multipart form besides doing it manually using just the raw post-data string as input I will try to adjust the Hyper example but any help will be much appreciated. Relevant issues: Support Multipart Forms . support rocket Rocket's primary abstraction for data is the FromData trait. Given the POST data and the request, you can construct a given type: pub trait FromData: Sized { type Error; fn from_data(request: &Request, data: Data) -> Outcome<Self, Self::Error>; } Then, it's just a matter of reading the API for

How to parse multipart forms using abonander/multipart with Rocket?

十年热恋 提交于 2019-11-30 17:11:06
问题 This might be useful for me: I have no idea how you're meant to go about parsing a multipart form besides doing it manually using just the raw post-data string as input I will try to adjust the Hyper example but any help will be much appreciated. Relevant issues: Support Multipart Forms. support rocket 回答1: Rocket's primary abstraction for data is the FromData trait. Given the POST data and the request, you can construct a given type: pub trait FromData: Sized { type Error; fn from_data