integrate editor into sdk

This commit is contained in:
appflowy 2021-07-22 22:26:38 +08:00
parent fa061ea832
commit 2bb332fb2c
37 changed files with 1438 additions and 12 deletions

View File

@ -0,0 +1,147 @@
///
// Generated code. Do not modify.
// source: doc_create.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class CreateDocRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CreateDocRequest', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'viewId')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
..hasRequiredFields = false
;
CreateDocRequest._() : super();
factory CreateDocRequest({
$core.String? viewId,
$core.String? name,
}) {
final _result = create();
if (viewId != null) {
_result.viewId = viewId;
}
if (name != null) {
_result.name = name;
}
return _result;
}
factory CreateDocRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory CreateDocRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
CreateDocRequest clone() => CreateDocRequest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
CreateDocRequest copyWith(void Function(CreateDocRequest) updates) => super.copyWith((message) => updates(message as CreateDocRequest)) as CreateDocRequest; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static CreateDocRequest create() => CreateDocRequest._();
CreateDocRequest createEmptyInstance() => create();
static $pb.PbList<CreateDocRequest> createRepeated() => $pb.PbList<CreateDocRequest>();
@$core.pragma('dart2js:noInline')
static CreateDocRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<CreateDocRequest>(create);
static CreateDocRequest? _defaultInstance;
@$pb.TagNumber(1)
$core.String get viewId => $_getSZ(0);
@$pb.TagNumber(1)
set viewId($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasViewId() => $_has(0);
@$pb.TagNumber(1)
void clearViewId() => clearField(1);
@$pb.TagNumber(2)
$core.String get name => $_getSZ(1);
@$pb.TagNumber(2)
set name($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasName() => $_has(1);
@$pb.TagNumber(2)
void clearName() => clearField(2);
}
class Doc extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'Doc', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'viewId')
..hasRequiredFields = false
;
Doc._() : super();
factory Doc({
$core.String? id,
$core.String? name,
$core.String? viewId,
}) {
final _result = create();
if (id != null) {
_result.id = id;
}
if (name != null) {
_result.name = name;
}
if (viewId != null) {
_result.viewId = viewId;
}
return _result;
}
factory Doc.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory Doc.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
Doc clone() => Doc()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
Doc copyWith(void Function(Doc) updates) => super.copyWith((message) => updates(message as Doc)) as Doc; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static Doc create() => Doc._();
Doc createEmptyInstance() => create();
static $pb.PbList<Doc> createRepeated() => $pb.PbList<Doc>();
@$core.pragma('dart2js:noInline')
static Doc getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Doc>(create);
static Doc? _defaultInstance;
@$pb.TagNumber(1)
$core.String get id => $_getSZ(0);
@$pb.TagNumber(1)
set id($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasId() => $_has(0);
@$pb.TagNumber(1)
void clearId() => clearField(1);
@$pb.TagNumber(2)
$core.String get name => $_getSZ(1);
@$pb.TagNumber(2)
set name($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasName() => $_has(1);
@$pb.TagNumber(2)
void clearName() => clearField(2);
@$pb.TagNumber(3)
$core.String get viewId => $_getSZ(2);
@$pb.TagNumber(3)
set viewId($core.String v) { $_setString(2, v); }
@$pb.TagNumber(3)
$core.bool hasViewId() => $_has(2);
@$pb.TagNumber(3)
void clearViewId() => clearField(3);
}

View File

@ -0,0 +1,7 @@
///
// Generated code. Do not modify.
// source: doc_create.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields

View File

@ -0,0 +1,33 @@
///
// Generated code. Do not modify.
// source: doc_create.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
import 'dart:core' as $core;
import 'dart:convert' as $convert;
import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use createDocRequestDescriptor instead')
const CreateDocRequest$json = const {
'1': 'CreateDocRequest',
'2': const [
const {'1': 'view_id', '3': 1, '4': 1, '5': 9, '10': 'viewId'},
const {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
],
};
/// Descriptor for `CreateDocRequest`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List createDocRequestDescriptor = $convert.base64Decode('ChBDcmVhdGVEb2NSZXF1ZXN0EhcKB3ZpZXdfaWQYASABKAlSBnZpZXdJZBISCgRuYW1lGAIgASgJUgRuYW1l');
@$core.Deprecated('Use docDescriptor instead')
const Doc$json = const {
'1': 'Doc',
'2': const [
const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'},
const {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
const {'1': 'view_id', '3': 3, '4': 1, '5': 9, '10': 'viewId'},
],
};
/// Descriptor for `Doc`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List docDescriptor = $convert.base64Decode('CgNEb2MSDgoCaWQYASABKAlSAmlkEhIKBG5hbWUYAiABKAlSBG5hbWUSFwoHdmlld19pZBgDIAEoCVIGdmlld0lk');

View File

@ -0,0 +1,9 @@
///
// Generated code. Do not modify.
// source: doc_create.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
export 'doc_create.pb.dart';

View File

@ -0,0 +1,76 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
import 'errors.pbenum.dart';
export 'errors.pbenum.dart';
class EditorError extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'EditorError', createEmptyInstance: create)
..e<EditorErrorCode>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code', $pb.PbFieldType.OE, defaultOrMaker: EditorErrorCode.Unknown, valueOf: EditorErrorCode.valueOf, enumValues: EditorErrorCode.values)
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'msg')
..hasRequiredFields = false
;
EditorError._() : super();
factory EditorError({
EditorErrorCode? code,
$core.String? msg,
}) {
final _result = create();
if (code != null) {
_result.code = code;
}
if (msg != null) {
_result.msg = msg;
}
return _result;
}
factory EditorError.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory EditorError.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
EditorError clone() => EditorError()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
EditorError copyWith(void Function(EditorError) updates) => super.copyWith((message) => updates(message as EditorError)) as EditorError; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static EditorError create() => EditorError._();
EditorError createEmptyInstance() => create();
static $pb.PbList<EditorError> createRepeated() => $pb.PbList<EditorError>();
@$core.pragma('dart2js:noInline')
static EditorError getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<EditorError>(create);
static EditorError? _defaultInstance;
@$pb.TagNumber(1)
EditorErrorCode get code => $_getN(0);
@$pb.TagNumber(1)
set code(EditorErrorCode v) { setField(1, v); }
@$pb.TagNumber(1)
$core.bool hasCode() => $_has(0);
@$pb.TagNumber(1)
void clearCode() => clearField(1);
@$pb.TagNumber(2)
$core.String get msg => $_getSZ(1);
@$pb.TagNumber(2)
set msg($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasMsg() => $_has(1);
@$pb.TagNumber(2)
void clearMsg() => clearField(2);
}

View File

@ -0,0 +1,30 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
// ignore_for_file: UNDEFINED_SHOWN_NAME
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class EditorErrorCode extends $pb.ProtobufEnum {
static const EditorErrorCode Unknown = EditorErrorCode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'Unknown');
static const EditorErrorCode EditorDBInternalError = EditorErrorCode._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'EditorDBInternalError');
static const EditorErrorCode DocNameInvalid = EditorErrorCode._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocNameInvalid');
static const EditorErrorCode DocViewIdInvalid = EditorErrorCode._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocViewIdInvalid');
static const $core.List<EditorErrorCode> values = <EditorErrorCode> [
Unknown,
EditorDBInternalError,
DocNameInvalid,
DocViewIdInvalid,
];
static final $core.Map<$core.int, EditorErrorCode> _byValue = $pb.ProtobufEnum.initByValue(values);
static EditorErrorCode? valueOf($core.int value) => _byValue[value];
const EditorErrorCode._($core.int v, $core.String n) : super(v, n);
}

View File

@ -0,0 +1,34 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
import 'dart:core' as $core;
import 'dart:convert' as $convert;
import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use editorErrorCodeDescriptor instead')
const EditorErrorCode$json = const {
'1': 'EditorErrorCode',
'2': const [
const {'1': 'Unknown', '2': 0},
const {'1': 'EditorDBInternalError', '2': 1},
const {'1': 'DocNameInvalid', '2': 10},
const {'1': 'DocViewIdInvalid', '2': 11},
],
};
/// Descriptor for `EditorErrorCode`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List editorErrorCodeDescriptor = $convert.base64Decode('Cg9FZGl0b3JFcnJvckNvZGUSCwoHVW5rbm93bhAAEhkKFUVkaXRvckRCSW50ZXJuYWxFcnJvchABEhIKDkRvY05hbWVJbnZhbGlkEAoSFAoQRG9jVmlld0lkSW52YWxpZBAL');
@$core.Deprecated('Use editorErrorDescriptor instead')
const EditorError$json = const {
'1': 'EditorError',
'2': const [
const {'1': 'code', '3': 1, '4': 1, '5': 14, '6': '.EditorErrorCode', '10': 'code'},
const {'1': 'msg', '3': 2, '4': 1, '5': 9, '10': 'msg'},
],
};
/// Descriptor for `EditorError`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List editorErrorDescriptor = $convert.base64Decode('CgtFZGl0b3JFcnJvchIkCgRjb2RlGAEgASgOMhAuRWRpdG9yRXJyb3JDb2RlUgRjb2RlEhAKA21zZxgCIAEoCVIDbXNn');

View File

@ -0,0 +1,9 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
export 'errors.pb.dart';

View File

@ -0,0 +1,11 @@
///
// Generated code. Do not modify.
// source: event.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
export 'event.pbenum.dart';

View File

@ -0,0 +1,24 @@
///
// Generated code. Do not modify.
// source: event.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
// ignore_for_file: UNDEFINED_SHOWN_NAME
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class EditorEvent extends $pb.ProtobufEnum {
static const EditorEvent CreateDoc = EditorEvent._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CreateDoc');
static const $core.List<EditorEvent> values = <EditorEvent> [
CreateDoc,
];
static final $core.Map<$core.int, EditorEvent> _byValue = $pb.ProtobufEnum.initByValue(values);
static EditorEvent? valueOf($core.int value) => _byValue[value];
const EditorEvent._($core.int v, $core.String n) : super(v, n);
}

View File

@ -0,0 +1,20 @@
///
// Generated code. Do not modify.
// source: event.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
import 'dart:core' as $core;
import 'dart:convert' as $convert;
import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use editorEventDescriptor instead')
const EditorEvent$json = const {
'1': 'EditorEvent',
'2': const [
const {'1': 'CreateDoc', '2': 0},
],
};
/// Descriptor for `EditorEvent`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List editorEventDescriptor = $convert.base64Decode('CgtFZGl0b3JFdmVudBINCglDcmVhdGVEb2MQAA==');

View File

@ -0,0 +1,9 @@
///
// Generated code. Do not modify.
// source: event.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
export 'event.pb.dart';

View File

@ -0,0 +1,4 @@
// Auto-generated, do not edit
export './doc_create.pb.dart';
export './errors.pb.dart';
export './event.pb.dart';

View File

@ -17,6 +17,9 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
"String" => TypeCategory::Str,
"ObservableSubject"
| "KeyValue"
| "CreateDocRequest"
| "Doc"
| "EditorError"
| "QueryAppRequest"
| "CreateAppRequest"
| "ColorStyle"
@ -43,7 +46,9 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
| "SignInParams"
| "UserError"
=> TypeCategory::Protobuf,
"ViewType"
"EditorEvent"
| "EditorErrorCode"
| "ViewType"
| "WorkspaceEvent"
| "WorkspaceErrorCode"
| "WorkspaceObservable"

View File

@ -12,4 +12,5 @@ flowy-log = { path = "../flowy-log" }
flowy-derive = { path = "../flowy-derive" }
flowy-database = { path = "../flowy-database" }
diesel = {version = "1.4.7", features = ["sqlite"]}
diesel_derives = {version = "1.4.1", features = ["sqlite"]}
diesel_derives = {version = "1.4.1", features = ["sqlite"]}
protobuf = {version = "2.18.0"}

View File

@ -20,7 +20,7 @@ pub struct CreateDocParams {
}
impl TryInto<CreateDocParams> for CreateDocRequest {
type Error = WorkspaceError;
type Error = EditorError;
fn try_into(self) -> Result<CreateDocParams, Self::Error> {
let name = DocName::parse(self.name)
@ -42,3 +42,15 @@ impl TryInto<CreateDocParams> for CreateDocRequest {
Ok(CreateDocParams { view_id, name })
}
}
#[derive(ProtoBuf, Default, Debug)]
pub struct Doc {
#[pb(index = 1)]
pub id: String,
#[pb(index = 2)]
pub name: String,
#[pb(index = 3)]
pub view_id: String,
}

View File

@ -6,7 +6,7 @@ use std::convert::TryInto;
#[derive(Debug, Default, Clone, ProtoBuf)]
pub struct EditorError {
#[pb(index = 1)]
pub code: UserErrorCode,
pub code: EditorErrorCode,
#[pb(index = 2)]
pub msg: String,
@ -36,8 +36,8 @@ pub enum EditorErrorCode {
DocViewIdInvalid = 11,
}
impl std::default::Default for UserErrorCode {
fn default() -> Self { UserErrorCode::Unknown }
impl std::default::Default for EditorErrorCode {
fn default() -> Self { EditorErrorCode::Unknown }
}
impl std::convert::From<flowy_database::result::Error> for EditorError {
@ -56,7 +56,7 @@ impl flowy_dispatch::Error for EditorError {
}
pub struct ErrorBuilder {
pub code: UserErrorCode,
pub code: EditorErrorCode,
pub msg: Option<String>,
}

View File

@ -0,0 +1,10 @@
use derive_more::Display;
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
#[event_err = "EditorError"]
pub enum EditorEvent {
#[display(fmt = "CreateDoc")]
#[event(input = "CreateDocRequest", output = "Doc")]
CreateDoc = 0,
}

View File

@ -1,2 +0,0 @@
mod file;
mod manager;

View File

@ -0,0 +1,15 @@
use crate::{entities::doc::*, errors::EditorError};
use flowy_dispatch::prelude::*;
use std::{convert::TryInto, sync::Arc};
pub async fn create_doc(
data: Data<CreateDocRequest>,
// session: ModuleData<Arc<UserSession>>,
) -> ResponseResult<Doc, EditorError> {
// let params: SignInParams = data.into_inner().try_into()?;
// let user = session.sign_in(params).await?;
// let user_detail = UserDetail::from(user);
// response_ok(user_detail)
panic!()
}

View File

@ -0,0 +1,3 @@
mod doc_handler;
pub use doc_handler::*;

View File

@ -1,6 +1,11 @@
mod entities;
mod errors;
mod event;
mod file_manager;
mod handlers;
mod module;
pub mod module;
mod protobuf;
mod services;
pub mod prelude {
pub use crate::module::*;
}

View File

@ -0,0 +1,12 @@
use crate::{event::EditorEvent, handlers::*, services::file_manager::FileManager};
use flowy_dispatch::prelude::*;
use std::sync::{Arc, RwLock};
pub fn create() -> Module {
let file_manager = RwLock::new(FileManager::new());
Module::new()
.name("Flowy-Editor")
.data(file_manager)
.event(EditorEvent::CreateDoc, create_doc)
}

View File

@ -0,0 +1,4 @@
mod model;
pub use model::*;

View File

@ -0,0 +1,504 @@
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unused_imports)]
#![allow(unused_results)]
//! Generated file from `doc_create.proto`
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
#[derive(PartialEq,Clone,Default)]
pub struct CreateDocRequest {
// message fields
pub view_id: ::std::string::String,
pub name: ::std::string::String,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a CreateDocRequest {
fn default() -> &'a CreateDocRequest {
<CreateDocRequest as ::protobuf::Message>::default_instance()
}
}
impl CreateDocRequest {
pub fn new() -> CreateDocRequest {
::std::default::Default::default()
}
// string view_id = 1;
pub fn get_view_id(&self) -> &str {
&self.view_id
}
pub fn clear_view_id(&mut self) {
self.view_id.clear();
}
// Param is passed by value, moved
pub fn set_view_id(&mut self, v: ::std::string::String) {
self.view_id = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_view_id(&mut self) -> &mut ::std::string::String {
&mut self.view_id
}
// Take field
pub fn take_view_id(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.view_id, ::std::string::String::new())
}
// string name = 2;
pub fn get_name(&self) -> &str {
&self.name
}
pub fn clear_name(&mut self) {
self.name.clear();
}
// Param is passed by value, moved
pub fn set_name(&mut self, v: ::std::string::String) {
self.name = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_name(&mut self) -> &mut ::std::string::String {
&mut self.name
}
// Take field
pub fn take_name(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.name, ::std::string::String::new())
}
}
impl ::protobuf::Message for CreateDocRequest {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.view_id)?;
},
2 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.name)?;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if !self.view_id.is_empty() {
my_size += ::protobuf::rt::string_size(1, &self.view_id);
}
if !self.name.is_empty() {
my_size += ::protobuf::rt::string_size(2, &self.name);
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if !self.view_id.is_empty() {
os.write_string(1, &self.view_id)?;
}
if !self.name.is_empty() {
os.write_string(2, &self.name)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> CreateDocRequest {
CreateDocRequest::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"view_id",
|m: &CreateDocRequest| { &m.view_id },
|m: &mut CreateDocRequest| { &mut m.view_id },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"name",
|m: &CreateDocRequest| { &m.name },
|m: &mut CreateDocRequest| { &mut m.name },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<CreateDocRequest>(
"CreateDocRequest",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static CreateDocRequest {
static instance: ::protobuf::rt::LazyV2<CreateDocRequest> = ::protobuf::rt::LazyV2::INIT;
instance.get(CreateDocRequest::new)
}
}
impl ::protobuf::Clear for CreateDocRequest {
fn clear(&mut self) {
self.view_id.clear();
self.name.clear();
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for CreateDocRequest {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for CreateDocRequest {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
#[derive(PartialEq,Clone,Default)]
pub struct Doc {
// message fields
pub id: ::std::string::String,
pub name: ::std::string::String,
pub view_id: ::std::string::String,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a Doc {
fn default() -> &'a Doc {
<Doc as ::protobuf::Message>::default_instance()
}
}
impl Doc {
pub fn new() -> Doc {
::std::default::Default::default()
}
// string id = 1;
pub fn get_id(&self) -> &str {
&self.id
}
pub fn clear_id(&mut self) {
self.id.clear();
}
// Param is passed by value, moved
pub fn set_id(&mut self, v: ::std::string::String) {
self.id = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_id(&mut self) -> &mut ::std::string::String {
&mut self.id
}
// Take field
pub fn take_id(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.id, ::std::string::String::new())
}
// string name = 2;
pub fn get_name(&self) -> &str {
&self.name
}
pub fn clear_name(&mut self) {
self.name.clear();
}
// Param is passed by value, moved
pub fn set_name(&mut self, v: ::std::string::String) {
self.name = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_name(&mut self) -> &mut ::std::string::String {
&mut self.name
}
// Take field
pub fn take_name(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.name, ::std::string::String::new())
}
// string view_id = 3;
pub fn get_view_id(&self) -> &str {
&self.view_id
}
pub fn clear_view_id(&mut self) {
self.view_id.clear();
}
// Param is passed by value, moved
pub fn set_view_id(&mut self, v: ::std::string::String) {
self.view_id = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_view_id(&mut self) -> &mut ::std::string::String {
&mut self.view_id
}
// Take field
pub fn take_view_id(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.view_id, ::std::string::String::new())
}
}
impl ::protobuf::Message for Doc {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?;
},
2 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.name)?;
},
3 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.view_id)?;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if !self.id.is_empty() {
my_size += ::protobuf::rt::string_size(1, &self.id);
}
if !self.name.is_empty() {
my_size += ::protobuf::rt::string_size(2, &self.name);
}
if !self.view_id.is_empty() {
my_size += ::protobuf::rt::string_size(3, &self.view_id);
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if !self.id.is_empty() {
os.write_string(1, &self.id)?;
}
if !self.name.is_empty() {
os.write_string(2, &self.name)?;
}
if !self.view_id.is_empty() {
os.write_string(3, &self.view_id)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> Doc {
Doc::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"id",
|m: &Doc| { &m.id },
|m: &mut Doc| { &mut m.id },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"name",
|m: &Doc| { &m.name },
|m: &mut Doc| { &mut m.name },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"view_id",
|m: &Doc| { &m.view_id },
|m: &mut Doc| { &mut m.view_id },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<Doc>(
"Doc",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static Doc {
static instance: ::protobuf::rt::LazyV2<Doc> = ::protobuf::rt::LazyV2::INIT;
instance.get(Doc::new)
}
}
impl ::protobuf::Clear for Doc {
fn clear(&mut self) {
self.id.clear();
self.name.clear();
self.view_id.clear();
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for Doc {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for Doc {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x10doc_create.proto\"?\n\x10CreateDocRequest\x12\x17\n\x07view_id\x18\
\x01\x20\x01(\tR\x06viewId\x12\x12\n\x04name\x18\x02\x20\x01(\tR\x04name\
\"B\n\x03Doc\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x12\n\x04name\
\x18\x02\x20\x01(\tR\x04name\x12\x17\n\x07view_id\x18\x03\x20\x01(\tR\
\x06viewIdJ\xd5\x02\n\x06\x12\x04\0\0\n\x01\n\x08\n\x01\x0c\x12\x03\0\0\
\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\
\x02\x08\x18\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x17\n\x0c\n\x05\x04\
\0\x02\0\x05\x12\x03\x03\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\
\x0b\x12\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x15\x16\n\x0b\n\x04\x04\
\0\x02\x01\x12\x03\x04\x04\x14\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\
\x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\x0b\x0f\n\x0c\n\x05\x04\
\0\x02\x01\x03\x12\x03\x04\x12\x13\n\n\n\x02\x04\x01\x12\x04\x06\0\n\x01\
\n\n\n\x03\x04\x01\x01\x12\x03\x06\x08\x0b\n\x0b\n\x04\x04\x01\x02\0\x12\
\x03\x07\x04\x12\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03\x07\x04\n\n\x0c\n\
\x05\x04\x01\x02\0\x01\x12\x03\x07\x0b\r\n\x0c\n\x05\x04\x01\x02\0\x03\
\x12\x03\x07\x10\x11\n\x0b\n\x04\x04\x01\x02\x01\x12\x03\x08\x04\x14\n\
\x0c\n\x05\x04\x01\x02\x01\x05\x12\x03\x08\x04\n\n\x0c\n\x05\x04\x01\x02\
\x01\x01\x12\x03\x08\x0b\x0f\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\x08\
\x12\x13\n\x0b\n\x04\x04\x01\x02\x02\x12\x03\t\x04\x17\n\x0c\n\x05\x04\
\x01\x02\x02\x05\x12\x03\t\x04\n\n\x0c\n\x05\x04\x01\x02\x02\x01\x12\x03\
\t\x0b\x12\n\x0c\n\x05\x04\x01\x02\x02\x03\x12\x03\t\x15\x16b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
}
pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
file_descriptor_proto_lazy.get(|| {
parse_descriptor_proto()
})
}

View File

@ -0,0 +1,307 @@
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unused_imports)]
#![allow(unused_results)]
//! Generated file from `errors.proto`
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
#[derive(PartialEq,Clone,Default)]
pub struct EditorError {
// message fields
pub code: EditorErrorCode,
pub msg: ::std::string::String,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a EditorError {
fn default() -> &'a EditorError {
<EditorError as ::protobuf::Message>::default_instance()
}
}
impl EditorError {
pub fn new() -> EditorError {
::std::default::Default::default()
}
// .EditorErrorCode code = 1;
pub fn get_code(&self) -> EditorErrorCode {
self.code
}
pub fn clear_code(&mut self) {
self.code = EditorErrorCode::Unknown;
}
// Param is passed by value, moved
pub fn set_code(&mut self, v: EditorErrorCode) {
self.code = v;
}
// string msg = 2;
pub fn get_msg(&self) -> &str {
&self.msg
}
pub fn clear_msg(&mut self) {
self.msg.clear();
}
// Param is passed by value, moved
pub fn set_msg(&mut self, v: ::std::string::String) {
self.msg = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_msg(&mut self) -> &mut ::std::string::String {
&mut self.msg
}
// Take field
pub fn take_msg(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.msg, ::std::string::String::new())
}
}
impl ::protobuf::Message for EditorError {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.code, 1, &mut self.unknown_fields)?
},
2 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.msg)?;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if self.code != EditorErrorCode::Unknown {
my_size += ::protobuf::rt::enum_size(1, self.code);
}
if !self.msg.is_empty() {
my_size += ::protobuf::rt::string_size(2, &self.msg);
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if self.code != EditorErrorCode::Unknown {
os.write_enum(1, ::protobuf::ProtobufEnum::value(&self.code))?;
}
if !self.msg.is_empty() {
os.write_string(2, &self.msg)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> EditorError {
EditorError::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum<EditorErrorCode>>(
"code",
|m: &EditorError| { &m.code },
|m: &mut EditorError| { &mut m.code },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"msg",
|m: &EditorError| { &m.msg },
|m: &mut EditorError| { &mut m.msg },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<EditorError>(
"EditorError",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static EditorError {
static instance: ::protobuf::rt::LazyV2<EditorError> = ::protobuf::rt::LazyV2::INIT;
instance.get(EditorError::new)
}
}
impl ::protobuf::Clear for EditorError {
fn clear(&mut self) {
self.code = EditorErrorCode::Unknown;
self.msg.clear();
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for EditorError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for EditorError {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
#[derive(Clone,PartialEq,Eq,Debug,Hash)]
pub enum EditorErrorCode {
Unknown = 0,
EditorDBInternalError = 1,
DocNameInvalid = 10,
DocViewIdInvalid = 11,
}
impl ::protobuf::ProtobufEnum for EditorErrorCode {
fn value(&self) -> i32 {
*self as i32
}
fn from_i32(value: i32) -> ::std::option::Option<EditorErrorCode> {
match value {
0 => ::std::option::Option::Some(EditorErrorCode::Unknown),
1 => ::std::option::Option::Some(EditorErrorCode::EditorDBInternalError),
10 => ::std::option::Option::Some(EditorErrorCode::DocNameInvalid),
11 => ::std::option::Option::Some(EditorErrorCode::DocViewIdInvalid),
_ => ::std::option::Option::None
}
}
fn values() -> &'static [Self] {
static values: &'static [EditorErrorCode] = &[
EditorErrorCode::Unknown,
EditorErrorCode::EditorDBInternalError,
EditorErrorCode::DocNameInvalid,
EditorErrorCode::DocViewIdInvalid,
];
values
}
fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
::protobuf::reflect::EnumDescriptor::new_pb_name::<EditorErrorCode>("EditorErrorCode", file_descriptor_proto())
})
}
}
impl ::std::marker::Copy for EditorErrorCode {
}
impl ::std::default::Default for EditorErrorCode {
fn default() -> Self {
EditorErrorCode::Unknown
}
}
impl ::protobuf::reflect::ProtobufValue for EditorErrorCode {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Enum(::protobuf::ProtobufEnum::descriptor(self))
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0cerrors.proto\"E\n\x0bEditorError\x12$\n\x04code\x18\x01\x20\x01(\
\x0e2\x10.EditorErrorCodeR\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\tR\
\x03msg*c\n\x0fEditorErrorCode\x12\x0b\n\x07Unknown\x10\0\x12\x19\n\x15E\
ditorDBInternalError\x10\x01\x12\x12\n\x0eDocNameInvalid\x10\n\x12\x14\n\
\x10DocViewIdInvalid\x10\x0bJ\xd4\x02\n\x06\x12\x04\0\0\x0b\x01\n\x08\n\
\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\
\x04\0\x01\x12\x03\x02\x08\x13\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\
\x1d\n\x0c\n\x05\x04\0\x02\0\x06\x12\x03\x03\x04\x13\n\x0c\n\x05\x04\0\
\x02\0\x01\x12\x03\x03\x14\x18\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\
\x1b\x1c\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x04\0\
\x02\x01\x05\x12\x03\x04\x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\
\x0b\x0e\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04\x11\x12\n\n\n\x02\x05\
\0\x12\x04\x06\0\x0b\x01\n\n\n\x03\x05\0\x01\x12\x03\x06\x05\x14\n\x0b\n\
\x04\x05\0\x02\0\x12\x03\x07\x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\
\x07\x04\x0b\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x07\x0e\x0f\n\x0b\n\x04\
\x05\0\x02\x01\x12\x03\x08\x04\x1e\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\
\x08\x04\x19\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x08\x1c\x1d\n\x0b\n\
\x04\x05\0\x02\x02\x12\x03\t\x04\x18\n\x0c\n\x05\x05\0\x02\x02\x01\x12\
\x03\t\x04\x12\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\t\x15\x17\n\x0b\n\
\x04\x05\0\x02\x03\x12\x03\n\x04\x1a\n\x0c\n\x05\x05\0\x02\x03\x01\x12\
\x03\n\x04\x14\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\n\x17\x19b\x06proto\
3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
}
pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
file_descriptor_proto_lazy.get(|| {
parse_descriptor_proto()
})
}

View File

@ -0,0 +1,91 @@
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unused_imports)]
#![allow(unused_results)]
//! Generated file from `event.proto`
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
#[derive(Clone,PartialEq,Eq,Debug,Hash)]
pub enum EditorEvent {
CreateDoc = 0,
}
impl ::protobuf::ProtobufEnum for EditorEvent {
fn value(&self) -> i32 {
*self as i32
}
fn from_i32(value: i32) -> ::std::option::Option<EditorEvent> {
match value {
0 => ::std::option::Option::Some(EditorEvent::CreateDoc),
_ => ::std::option::Option::None
}
}
fn values() -> &'static [Self] {
static values: &'static [EditorEvent] = &[
EditorEvent::CreateDoc,
];
values
}
fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
::protobuf::reflect::EnumDescriptor::new_pb_name::<EditorEvent>("EditorEvent", file_descriptor_proto())
})
}
}
impl ::std::marker::Copy for EditorEvent {
}
impl ::std::default::Default for EditorEvent {
fn default() -> Self {
EditorEvent::CreateDoc
}
}
impl ::protobuf::reflect::ProtobufValue for EditorEvent {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Enum(::protobuf::ProtobufEnum::descriptor(self))
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0bevent.proto*\x1c\n\x0bEditorEvent\x12\r\n\tCreateDoc\x10\0JS\n\x06\
\x12\x04\0\0\x03\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x05\0\x12\
\x04\x01\0\x03\x01\n\n\n\x03\x05\0\x01\x12\x03\x01\x05\x10\n\x0b\n\x04\
\x05\0\x02\0\x12\x03\x02\x04\x12\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x02\
\x04\r\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x02\x10\x11b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
}
pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
file_descriptor_proto_lazy.get(|| {
parse_descriptor_proto()
})
}

View File

@ -0,0 +1,10 @@
// Auto-generated, do not edit
mod doc_create;
pub use doc_create::*;
mod errors;
pub use errors::*;
mod event;
pub use event::*;

View File

@ -0,0 +1,11 @@
syntax = "proto3";
message CreateDocRequest {
string view_id = 1;
string name = 2;
}
message Doc {
string id = 1;
string name = 2;
string view_id = 3;
}

View File

@ -0,0 +1,12 @@
syntax = "proto3";
message EditorError {
EditorErrorCode code = 1;
string msg = 2;
}
enum EditorErrorCode {
Unknown = 0;
EditorDBInternalError = 1;
DocNameInvalid = 10;
DocViewIdInvalid = 11;
}

View File

@ -0,0 +1,4 @@
syntax = "proto3";
enum EditorEvent {
CreateDoc = 0;
}

View File

@ -1,4 +1,4 @@
use crate::file_manager::file::*;
use crate::services::file_manager::*;
use std::{
collections::HashMap,
path::{Path, PathBuf},

View File

@ -0,0 +1,5 @@
mod file;
mod manager;
pub use file::*;
pub use manager::*;

View File

@ -0,0 +1 @@
pub mod file_manager;

View File

@ -13,6 +13,7 @@ flowy-user = { path = "../flowy-user" }
flowy-infra = { path = "../flowy-infra" }
flowy-workspace = { path = "../flowy-workspace" }
flowy-database = { path = "../flowy-database" }
flowy-editor = { path = "../flowy-editor" }
tracing = { version = "0.1" }
log = "0.4.14"
futures-core = { version = "0.3", default-features = false }

View File

@ -1,5 +1,6 @@
use crate::flowy_server::{ArcFlowyServer, FlowyServerMocker};
use flowy_dispatch::prelude::Module;
use flowy_editor::prelude::*;
use flowy_user::prelude::*;
use crate::deps_resolve::{WorkspaceDatabaseImpl, WorkspaceUserImpl};
@ -27,5 +28,6 @@ pub fn build_modules(config: ModuleConfig, _server: ArcFlowyServer) -> Vec<Modul
vec![
flowy_user::module::create(user_session),
flowy_workspace::module::create(workspace_user_impl, workspace_data_impl),
flowy_editor::module::create(),
]
}