move types in crate::types to crate::server

This commit is contained in:
Dustin J. Mitchell 2020-11-26 11:34:04 -05:00
parent e84871931f
commit 2457d8bc43
5 changed files with 20 additions and 24 deletions

View file

@ -1,7 +1,7 @@
use crate::api::{ use crate::api::{
ServerState, HISTORY_SEGMENT_CONTENT_TYPE, PARENT_VERSION_ID_HEADER, VERSION_ID_HEADER, ServerState, HISTORY_SEGMENT_CONTENT_TYPE, PARENT_VERSION_ID_HEADER, VERSION_ID_HEADER,
}; };
use crate::types::{AddVersionResult, ClientId, VersionId}; use crate::server::{AddVersionResult, ClientId, VersionId};
use actix_web::{ use actix_web::{
error, http::StatusCode, post, web, HttpMessage, HttpRequest, HttpResponse, Result, error, http::StatusCode, post, web, HttpMessage, HttpRequest, HttpResponse, Result,
}; };

View file

@ -1,7 +1,7 @@
use crate::api::{ use crate::api::{
ServerState, HISTORY_SEGMENT_CONTENT_TYPE, PARENT_VERSION_ID_HEADER, VERSION_ID_HEADER, ServerState, HISTORY_SEGMENT_CONTENT_TYPE, PARENT_VERSION_ID_HEADER, VERSION_ID_HEADER,
}; };
use crate::types::{ClientId, VersionId}; use crate::server::{ClientId, VersionId};
use actix_web::{error, get, http::StatusCode, web, HttpResponse, Result}; use actix_web::{error, get, http::StatusCode, web, HttpResponse, Result};
/// Get a child version. /// Get a child version.

View file

@ -4,7 +4,6 @@ use server::{NullSyncServer, SyncServer};
mod api; mod api;
mod server; mod server;
mod types;
// TODO: use hawk to sign requests // TODO: use hawk to sign requests

View file

@ -1,7 +1,24 @@
use crate::types::{AddVersionResult, ClientId, GetVersionResult, HistorySegment, VersionId};
use failure::Fallible; use failure::Fallible;
use taskchampion::Uuid; use taskchampion::Uuid;
pub(crate) type HistorySegment = Vec<u8>;
pub(crate) type ClientId = Uuid;
pub(crate) type VersionId = Uuid;
/// Response to get_child_version
pub(crate) struct GetVersionResult {
pub(crate) version_id: Uuid,
pub(crate) parent_version_id: Uuid,
pub(crate) history_segment: HistorySegment,
}
/// Response to add_version
pub(crate) enum AddVersionResult {
/// OK, version added with the given ID
Ok(VersionId),
/// Rejected; expected a version with the given parent version
ExpectedParentVersion(VersionId),
}
pub(crate) trait SyncServer: Sync + Send { pub(crate) trait SyncServer: Sync + Send {
fn get_child_version( fn get_child_version(
&self, &self,

View file

@ -1,20 +0,0 @@
use taskchampion::Uuid;
pub(crate) type HistorySegment = Vec<u8>;
pub(crate) type ClientId = Uuid;
pub(crate) type VersionId = Uuid;
/// Response to get_child_version
pub(crate) struct GetVersionResult {
pub(crate) version_id: Uuid,
pub(crate) parent_version_id: Uuid,
pub(crate) history_segment: HistorySegment,
}
/// Response to add_version
pub(crate) enum AddVersionResult {
/// OK, version added with the given ID
Ok(VersionId),
/// Rejected; expected a version with the given parent version
ExpectedParentVersion(VersionId),
}