97e24d0d41
* Add record migration * Add database functions for inserting history No real tests yet :( I would like to avoid running postgres lol * Add index handler, use UUIDs not strings * Fix a bunch of tests, remove Option<Uuid> * Add tests, all passing * Working upload sync * Record downloading works * Sync download works * Don't waste requests * Use a page size for uploads, make it variable later * Aaaaaand they're encrypted now too * Add cek * Allow reading tail across hosts * Revert "Allow reading tail across hosts" Not like that This reverts commit 7b0c72e7e050c358172f9b53cbd21b9e44cf4931. * Handle multiple shards properly * format * Format and make clippy happy * use some fancy types (#1098) * use some fancy types * fmt * Goodbye horrible tuple * Update atuin-server-postgres/migrations/20230623070418_records.sql Co-authored-by: Conrad Ludgate <conradludgate@gmail.com> * fmt * Sort tests too because time sucks * fix features --------- Co-authored-by: Conrad Ludgate <conradludgate@gmail.com>
57 lines
1.4 KiB
Rust
57 lines
1.4 KiB
Rust
#![forbid(unsafe_code)]
|
|
|
|
/// Defines a new UUID type wrapper
|
|
macro_rules! new_uuid {
|
|
($name:ident) => {
|
|
#[derive(
|
|
Debug,
|
|
Copy,
|
|
Clone,
|
|
PartialEq,
|
|
Eq,
|
|
Hash,
|
|
PartialOrd,
|
|
Ord,
|
|
serde::Serialize,
|
|
serde::Deserialize,
|
|
)]
|
|
#[serde(transparent)]
|
|
pub struct $name(pub Uuid);
|
|
|
|
impl<DB: sqlx::Database> sqlx::Type<DB> for $name
|
|
where
|
|
Uuid: sqlx::Type<DB>,
|
|
{
|
|
fn type_info() -> <DB as sqlx::Database>::TypeInfo {
|
|
Uuid::type_info()
|
|
}
|
|
}
|
|
|
|
impl<'r, DB: sqlx::Database> sqlx::Decode<'r, DB> for $name
|
|
where
|
|
Uuid: sqlx::Decode<'r, DB>,
|
|
{
|
|
fn decode(
|
|
value: <DB as sqlx::database::HasValueRef<'r>>::ValueRef,
|
|
) -> std::result::Result<Self, sqlx::error::BoxDynError> {
|
|
Uuid::decode(value).map(Self)
|
|
}
|
|
}
|
|
|
|
impl<'q, DB: sqlx::Database> sqlx::Encode<'q, DB> for $name
|
|
where
|
|
Uuid: sqlx::Encode<'q, DB>,
|
|
{
|
|
fn encode_by_ref(
|
|
&self,
|
|
buf: &mut <DB as sqlx::database::HasArguments<'q>>::ArgumentBuffer,
|
|
) -> sqlx::encode::IsNull {
|
|
self.0.encode_by_ref(buf)
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
pub mod api;
|
|
pub mod record;
|
|
pub mod utils;
|