blob: b97f8afe37bbc9e03dc6f45e2c90cc1d23576f9c [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace p2p_sync;
// Handshake. Gives the host_name of the device. Will be the first message
// once a connection is established.
table Handshake {
version: ushort;
host_name: [ubyte];
}
table NamespacePageId {
namespace_id: [ubyte];
page_id: [ubyte];
}
// Request that the other side starts sending us new commits.
// There is no guarantee that the other side actually sends data over, or at
// which frequency (for instance, if low on battery).
table WatchStartRequest {}
// Request that the other side stops sending us new commits.
table WatchStopRequest {}
table Data {
bytes: [ubyte];
}
table CommitId {
id: [ubyte];
}
// Request commit data.
table CommitRequest {
commit_ids: [CommitId];
}
enum CommitStatus : ushort {
OK,
// No commit by this id is known.
UNKNOWN_COMMIT,
}
table Commit {
id: CommitId;
status: CommitStatus;
commit: Data;
}
table CommitResponse {
commits: [Commit];
}
table ObjectId {
key_index: uint;
deletion_scope_id: uint;
digest: [ubyte];
}
// Request some objects.
table ObjectRequest {
object_ids: [ObjectId];
}
enum ObjectStatus : ushort {
OK,
// No object by this id is known.
UNKNOWN_OBJECT,
}
// Whether an object is known to be synced to the cloud.
enum ObjectSyncStatus : ubyte {
// The object is not known to be synced to the cloud.
UNSYNCED,
// The object is known to be synced to the cloud.
SYNCED_TO_CLOUD,
}
table Object {
id: ObjectId;
status: ObjectStatus;
data: Data;
sync_status: ObjectSyncStatus;
}
table ObjectResponse {
objects: [Object];
}
union RequestMessage {
WatchStartRequest,
WatchStopRequest,
CommitRequest,
ObjectRequest,
}
table Request {
namespace_page: NamespacePageId;
request: RequestMessage;
}
union ResponseMessage {
CommitResponse,
ObjectResponse,
}
enum ResponseStatus : ushort {
OK,
// No namespace by this name is known. Requesting side should stop sending
// requests for this namespace.
UNKNOWN_NAMESPACE,
// No page by this name is known in this ledger. Requesting side should stop
// sending requests for this page.
UNKNOWN_PAGE,
}
table Response {
status: ResponseStatus;
namespace_page: NamespacePageId;
response: ResponseMessage;
}
union MessageUnion {
Request,
Response,
}
// Message contains the business-logic messages sent between devices.
table Message {
message: MessageUnion;
}
root_type Message;