cargo fmt
This commit is contained in:
parent
4eb9049a1a
commit
2bbab69e94
2 changed files with 10 additions and 8 deletions
|
@ -60,16 +60,15 @@ pub fn generate_id() -> String {
|
||||||
pub async fn store_paste(id: String, content: String) {
|
pub async fn store_paste(id: String, content: String) {
|
||||||
purge_old().await;
|
purge_old().await;
|
||||||
|
|
||||||
ENTRIES
|
ENTRIES.write().await.insert(id, content);
|
||||||
.write()
|
|
||||||
.await
|
|
||||||
.insert(id, content);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a paste by id.
|
/// Get a paste by id.
|
||||||
///
|
///
|
||||||
/// Returns `None` if the paste doesn't exist.
|
/// Returns `None` if the paste doesn't exist.
|
||||||
pub async fn get_paste(id: &str) -> Option<RwLockReadGuardRef<'_, LinkedHashMap<String, String>, String>> {
|
pub async fn get_paste(
|
||||||
|
id: &str,
|
||||||
|
) -> Option<RwLockReadGuardRef<'_, LinkedHashMap<String, String>, String>> {
|
||||||
// need to box the guard until owning_ref understands Pin is a stable address
|
// need to box the guard until owning_ref understands Pin is a stable address
|
||||||
let or = RwLockReadGuardRef::new(Box::new(ENTRIES.read().await));
|
let or = RwLockReadGuardRef::new(Box::new(ENTRIES.read().await));
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,11 @@ async fn submit(input: Form<IndexForm>) -> Redirect {
|
||||||
#[put("/", data = "<input>")]
|
#[put("/", data = "<input>")]
|
||||||
async fn submit_raw(input: Data, host: HostHeader<'_>) -> Result<String, Status> {
|
async fn submit_raw(input: Data, host: HostHeader<'_>) -> Result<String, Status> {
|
||||||
let mut data = String::new();
|
let mut data = String::new();
|
||||||
input.open().take(1024 * 1000)
|
input
|
||||||
.read_to_string(&mut data).await
|
.open()
|
||||||
|
.take(1024 * 1000)
|
||||||
|
.read_to_string(&mut data)
|
||||||
|
.await
|
||||||
.map_err(|_| Status::InternalServerError)?;
|
.map_err(|_| Status::InternalServerError)?;
|
||||||
|
|
||||||
let id = generate_id();
|
let id = generate_id();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue