mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
test read file & save file in flowy-editor
This commit is contained in:
parent
4e80b296f8
commit
c27f616ddb
@ -84,23 +84,21 @@ class CreateDocRequest extends $pb.GeneratedMessage {
|
||||
void clearDesc() => clearField(3);
|
||||
}
|
||||
|
||||
class Doc extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'Doc', createEmptyInstance: create)
|
||||
class DocDescription extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DocDescription', 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') ? '' : 'desc')
|
||||
..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'path')
|
||||
..aOS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'content')
|
||||
..hasRequiredFields = false
|
||||
;
|
||||
|
||||
Doc._() : super();
|
||||
factory Doc({
|
||||
DocDescription._() : super();
|
||||
factory DocDescription({
|
||||
$core.String? id,
|
||||
$core.String? name,
|
||||
$core.String? desc,
|
||||
$core.String? path,
|
||||
$core.String? content,
|
||||
}) {
|
||||
final _result = create();
|
||||
if (id != null) {
|
||||
@ -115,31 +113,28 @@ class Doc extends $pb.GeneratedMessage {
|
||||
if (path != null) {
|
||||
_result.path = path;
|
||||
}
|
||||
if (content != null) {
|
||||
_result.content = content;
|
||||
}
|
||||
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);
|
||||
factory DocDescription.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory DocDescription.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);
|
||||
DocDescription clone() => DocDescription()..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
|
||||
DocDescription copyWith(void Function(DocDescription) updates) => super.copyWith((message) => updates(message as DocDescription)) as DocDescription; // 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>();
|
||||
static DocDescription create() => DocDescription._();
|
||||
DocDescription createEmptyInstance() => create();
|
||||
static $pb.PbList<DocDescription> createRepeated() => $pb.PbList<DocDescription>();
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static Doc getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Doc>(create);
|
||||
static Doc? _defaultInstance;
|
||||
static DocDescription getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<DocDescription>(create);
|
||||
static DocDescription? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
$core.String get id => $_getSZ(0);
|
||||
@ -176,14 +171,68 @@ class Doc extends $pb.GeneratedMessage {
|
||||
$core.bool hasPath() => $_has(3);
|
||||
@$pb.TagNumber(4)
|
||||
void clearPath() => clearField(4);
|
||||
|
||||
@$pb.TagNumber(5)
|
||||
$core.String get content => $_getSZ(4);
|
||||
@$pb.TagNumber(5)
|
||||
set content($core.String v) { $_setString(4, v); }
|
||||
@$pb.TagNumber(5)
|
||||
$core.bool hasContent() => $_has(4);
|
||||
@$pb.TagNumber(5)
|
||||
void clearContent() => clearField(5);
|
||||
}
|
||||
|
||||
class Doc extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'Doc', createEmptyInstance: create)
|
||||
..aOM<DocDescription>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'desc', subBuilder: DocDescription.create)
|
||||
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'content')
|
||||
..hasRequiredFields = false
|
||||
;
|
||||
|
||||
Doc._() : super();
|
||||
factory Doc({
|
||||
DocDescription? desc,
|
||||
$core.String? content,
|
||||
}) {
|
||||
final _result = create();
|
||||
if (desc != null) {
|
||||
_result.desc = desc;
|
||||
}
|
||||
if (content != null) {
|
||||
_result.content = content;
|
||||
}
|
||||
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)
|
||||
DocDescription get desc => $_getN(0);
|
||||
@$pb.TagNumber(1)
|
||||
set desc(DocDescription v) { setField(1, v); }
|
||||
@$pb.TagNumber(1)
|
||||
$core.bool hasDesc() => $_has(0);
|
||||
@$pb.TagNumber(1)
|
||||
void clearDesc() => clearField(1);
|
||||
@$pb.TagNumber(1)
|
||||
DocDescription ensureDesc() => $_ensure(0);
|
||||
|
||||
@$pb.TagNumber(2)
|
||||
$core.String get content => $_getSZ(1);
|
||||
@$pb.TagNumber(2)
|
||||
set content($core.String v) { $_setString(1, v); }
|
||||
@$pb.TagNumber(2)
|
||||
$core.bool hasContent() => $_has(1);
|
||||
@$pb.TagNumber(2)
|
||||
void clearContent() => clearField(2);
|
||||
}
|
||||
|
||||
|
@ -20,17 +20,27 @@ const CreateDocRequest$json = const {
|
||||
|
||||
/// Descriptor for `CreateDocRequest`. Decode as a `google.protobuf.DescriptorProto`.
|
||||
final $typed_data.Uint8List createDocRequestDescriptor = $convert.base64Decode('ChBDcmVhdGVEb2NSZXF1ZXN0Eg4KAmlkGAEgASgJUgJpZBISCgRuYW1lGAIgASgJUgRuYW1lEhIKBGRlc2MYAyABKAlSBGRlc2M=');
|
||||
@$core.Deprecated('Use docDescriptor instead')
|
||||
const Doc$json = const {
|
||||
'1': 'Doc',
|
||||
@$core.Deprecated('Use docDescriptionDescriptor instead')
|
||||
const DocDescription$json = const {
|
||||
'1': 'DocDescription',
|
||||
'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': 'desc', '3': 3, '4': 1, '5': 9, '10': 'desc'},
|
||||
const {'1': 'path', '3': 4, '4': 1, '5': 9, '10': 'path'},
|
||||
const {'1': 'content', '3': 5, '4': 1, '5': 9, '10': 'content'},
|
||||
],
|
||||
};
|
||||
|
||||
/// Descriptor for `DocDescription`. Decode as a `google.protobuf.DescriptorProto`.
|
||||
final $typed_data.Uint8List docDescriptionDescriptor = $convert.base64Decode('Cg5Eb2NEZXNjcmlwdGlvbhIOCgJpZBgBIAEoCVICaWQSEgoEbmFtZRgCIAEoCVIEbmFtZRISCgRkZXNjGAMgASgJUgRkZXNjEhIKBHBhdGgYBCABKAlSBHBhdGg=');
|
||||
@$core.Deprecated('Use docDescriptor instead')
|
||||
const Doc$json = const {
|
||||
'1': 'Doc',
|
||||
'2': const [
|
||||
const {'1': 'desc', '3': 1, '4': 1, '5': 11, '6': '.DocDescription', '10': 'desc'},
|
||||
const {'1': 'content', '3': 2, '4': 1, '5': 9, '10': 'content'},
|
||||
],
|
||||
};
|
||||
|
||||
/// Descriptor for `Doc`. Decode as a `google.protobuf.DescriptorProto`.
|
||||
final $typed_data.Uint8List docDescriptor = $convert.base64Decode('CgNEb2MSDgoCaWQYASABKAlSAmlkEhIKBG5hbWUYAiABKAlSBG5hbWUSEgoEZGVzYxgDIAEoCVIEZGVzYxISCgRwYXRoGAQgASgJUgRwYXRoEhgKB2NvbnRlbnQYBSABKAlSB2NvbnRlbnQ=');
|
||||
final $typed_data.Uint8List docDescriptor = $convert.base64Decode('CgNEb2MSIwoEZGVzYxgBIAEoCzIPLkRvY0Rlc2NyaXB0aW9uUgRkZXNjEhgKB2NvbnRlbnQYAiABKAlSB2NvbnRlbnQ=');
|
||||
|
@ -0,0 +1,139 @@
|
||||
///
|
||||
// Generated code. Do not modify.
|
||||
// source: doc_modify.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;
|
||||
|
||||
enum UpdateDocRequest_OneOfName {
|
||||
name,
|
||||
notSet
|
||||
}
|
||||
|
||||
enum UpdateDocRequest_OneOfDesc {
|
||||
desc,
|
||||
notSet
|
||||
}
|
||||
|
||||
enum UpdateDocRequest_OneOfContent {
|
||||
content,
|
||||
notSet
|
||||
}
|
||||
|
||||
class UpdateDocRequest extends $pb.GeneratedMessage {
|
||||
static const $core.Map<$core.int, UpdateDocRequest_OneOfName> _UpdateDocRequest_OneOfNameByTag = {
|
||||
2 : UpdateDocRequest_OneOfName.name,
|
||||
0 : UpdateDocRequest_OneOfName.notSet
|
||||
};
|
||||
static const $core.Map<$core.int, UpdateDocRequest_OneOfDesc> _UpdateDocRequest_OneOfDescByTag = {
|
||||
3 : UpdateDocRequest_OneOfDesc.desc,
|
||||
0 : UpdateDocRequest_OneOfDesc.notSet
|
||||
};
|
||||
static const $core.Map<$core.int, UpdateDocRequest_OneOfContent> _UpdateDocRequest_OneOfContentByTag = {
|
||||
4 : UpdateDocRequest_OneOfContent.content,
|
||||
0 : UpdateDocRequest_OneOfContent.notSet
|
||||
};
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UpdateDocRequest', createEmptyInstance: create)
|
||||
..oo(0, [2])
|
||||
..oo(1, [3])
|
||||
..oo(2, [4])
|
||||
..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') ? '' : 'desc')
|
||||
..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'content')
|
||||
..hasRequiredFields = false
|
||||
;
|
||||
|
||||
UpdateDocRequest._() : super();
|
||||
factory UpdateDocRequest({
|
||||
$core.String? id,
|
||||
$core.String? name,
|
||||
$core.String? desc,
|
||||
$core.String? content,
|
||||
}) {
|
||||
final _result = create();
|
||||
if (id != null) {
|
||||
_result.id = id;
|
||||
}
|
||||
if (name != null) {
|
||||
_result.name = name;
|
||||
}
|
||||
if (desc != null) {
|
||||
_result.desc = desc;
|
||||
}
|
||||
if (content != null) {
|
||||
_result.content = content;
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
factory UpdateDocRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory UpdateDocRequest.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')
|
||||
UpdateDocRequest clone() => UpdateDocRequest()..mergeFromMessage(this);
|
||||
@$core.Deprecated(
|
||||
'Using this can add significant overhead to your binary. '
|
||||
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
|
||||
'Will be removed in next major version')
|
||||
UpdateDocRequest copyWith(void Function(UpdateDocRequest) updates) => super.copyWith((message) => updates(message as UpdateDocRequest)) as UpdateDocRequest; // ignore: deprecated_member_use
|
||||
$pb.BuilderInfo get info_ => _i;
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static UpdateDocRequest create() => UpdateDocRequest._();
|
||||
UpdateDocRequest createEmptyInstance() => create();
|
||||
static $pb.PbList<UpdateDocRequest> createRepeated() => $pb.PbList<UpdateDocRequest>();
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static UpdateDocRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UpdateDocRequest>(create);
|
||||
static UpdateDocRequest? _defaultInstance;
|
||||
|
||||
UpdateDocRequest_OneOfName whichOneOfName() => _UpdateDocRequest_OneOfNameByTag[$_whichOneof(0)]!;
|
||||
void clearOneOfName() => clearField($_whichOneof(0));
|
||||
|
||||
UpdateDocRequest_OneOfDesc whichOneOfDesc() => _UpdateDocRequest_OneOfDescByTag[$_whichOneof(1)]!;
|
||||
void clearOneOfDesc() => clearField($_whichOneof(1));
|
||||
|
||||
UpdateDocRequest_OneOfContent whichOneOfContent() => _UpdateDocRequest_OneOfContentByTag[$_whichOneof(2)]!;
|
||||
void clearOneOfContent() => clearField($_whichOneof(2));
|
||||
|
||||
@$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 desc => $_getSZ(2);
|
||||
@$pb.TagNumber(3)
|
||||
set desc($core.String v) { $_setString(2, v); }
|
||||
@$pb.TagNumber(3)
|
||||
$core.bool hasDesc() => $_has(2);
|
||||
@$pb.TagNumber(3)
|
||||
void clearDesc() => clearField(3);
|
||||
|
||||
@$pb.TagNumber(4)
|
||||
$core.String get content => $_getSZ(3);
|
||||
@$pb.TagNumber(4)
|
||||
set content($core.String v) { $_setString(3, v); }
|
||||
@$pb.TagNumber(4)
|
||||
$core.bool hasContent() => $_has(3);
|
||||
@$pb.TagNumber(4)
|
||||
void clearContent() => clearField(4);
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
///
|
||||
// Generated code. Do not modify.
|
||||
// source: doc_modify.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
|
||||
|
@ -0,0 +1,28 @@
|
||||
///
|
||||
// Generated code. Do not modify.
|
||||
// source: doc_modify.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 updateDocRequestDescriptor instead')
|
||||
const UpdateDocRequest$json = const {
|
||||
'1': 'UpdateDocRequest',
|
||||
'2': const [
|
||||
const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'},
|
||||
const {'1': 'name', '3': 2, '4': 1, '5': 9, '9': 0, '10': 'name'},
|
||||
const {'1': 'desc', '3': 3, '4': 1, '5': 9, '9': 1, '10': 'desc'},
|
||||
const {'1': 'content', '3': 4, '4': 1, '5': 9, '9': 2, '10': 'content'},
|
||||
],
|
||||
'8': const [
|
||||
const {'1': 'one_of_name'},
|
||||
const {'1': 'one_of_desc'},
|
||||
const {'1': 'one_of_content'},
|
||||
],
|
||||
};
|
||||
|
||||
/// Descriptor for `UpdateDocRequest`. Decode as a `google.protobuf.DescriptorProto`.
|
||||
final $typed_data.Uint8List updateDocRequestDescriptor = $convert.base64Decode('ChBVcGRhdGVEb2NSZXF1ZXN0Eg4KAmlkGAEgASgJUgJpZBIUCgRuYW1lGAIgASgJSABSBG5hbWUSFAoEZGVzYxgDIAEoCUgBUgRkZXNjEhoKB2NvbnRlbnQYBCABKAlIAlIHY29udGVudEINCgtvbmVfb2ZfbmFtZUINCgtvbmVfb2ZfZGVzY0IQCg5vbmVfb2ZfY29udGVudA==');
|
@ -0,0 +1,9 @@
|
||||
///
|
||||
// Generated code. Do not modify.
|
||||
// source: doc_modify.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_modify.pb.dart';
|
||||
|
@ -12,22 +12,17 @@ import 'package:protobuf/protobuf.dart' as $pb;
|
||||
class QueryDocRequest extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'QueryDocRequest', createEmptyInstance: create)
|
||||
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'docId')
|
||||
..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'readContent')
|
||||
..hasRequiredFields = false
|
||||
;
|
||||
|
||||
QueryDocRequest._() : super();
|
||||
factory QueryDocRequest({
|
||||
$core.String? docId,
|
||||
$core.bool? readContent,
|
||||
}) {
|
||||
final _result = create();
|
||||
if (docId != null) {
|
||||
_result.docId = docId;
|
||||
}
|
||||
if (readContent != null) {
|
||||
_result.readContent = readContent;
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
factory QueryDocRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
@ -59,14 +54,5 @@ class QueryDocRequest extends $pb.GeneratedMessage {
|
||||
$core.bool hasDocId() => $_has(0);
|
||||
@$pb.TagNumber(1)
|
||||
void clearDocId() => clearField(1);
|
||||
|
||||
@$pb.TagNumber(2)
|
||||
$core.bool get readContent => $_getBF(1);
|
||||
@$pb.TagNumber(2)
|
||||
set readContent($core.bool v) { $_setBool(1, v); }
|
||||
@$pb.TagNumber(2)
|
||||
$core.bool hasReadContent() => $_has(1);
|
||||
@$pb.TagNumber(2)
|
||||
void clearReadContent() => clearField(2);
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,8 @@ const QueryDocRequest$json = const {
|
||||
'1': 'QueryDocRequest',
|
||||
'2': const [
|
||||
const {'1': 'doc_id', '3': 1, '4': 1, '5': 9, '10': 'docId'},
|
||||
const {'1': 'read_content', '3': 2, '4': 1, '5': 8, '10': 'readContent'},
|
||||
],
|
||||
};
|
||||
|
||||
/// Descriptor for `QueryDocRequest`. Decode as a `google.protobuf.DescriptorProto`.
|
||||
final $typed_data.Uint8List queryDocRequestDescriptor = $convert.base64Decode('Cg9RdWVyeURvY1JlcXVlc3QSFQoGZG9jX2lkGAEgASgJUgVkb2NJZBIhCgxyZWFkX2NvbnRlbnQYAiABKAhSC3JlYWRDb250ZW50');
|
||||
final $typed_data.Uint8List queryDocRequestDescriptor = $convert.base64Decode('Cg9RdWVyeURvY1JlcXVlc3QSFQoGZG9jX2lkGAEgASgJUgVkb2NJZA==');
|
||||
|
@ -12,14 +12,20 @@ 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 EditorDBConnFailed = EditorErrorCode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'EditorDBConnFailed');
|
||||
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 EditorErrorCode DocDescTooLong = EditorErrorCode._(12, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocDescTooLong');
|
||||
static const EditorErrorCode DocFileError = EditorErrorCode._(13, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocFileError');
|
||||
|
||||
static const $core.List<EditorErrorCode> values = <EditorErrorCode> [
|
||||
Unknown,
|
||||
EditorDBInternalError,
|
||||
EditorDBConnFailed,
|
||||
DocNameInvalid,
|
||||
DocViewIdInvalid,
|
||||
DocDescTooLong,
|
||||
DocFileError,
|
||||
];
|
||||
|
||||
static final $core.Map<$core.int, EditorErrorCode> _byValue = $pb.ProtobufEnum.initByValue(values);
|
||||
|
@ -14,13 +14,16 @@ const EditorErrorCode$json = const {
|
||||
'2': const [
|
||||
const {'1': 'Unknown', '2': 0},
|
||||
const {'1': 'EditorDBInternalError', '2': 1},
|
||||
const {'1': 'EditorDBConnFailed', '2': 2},
|
||||
const {'1': 'DocNameInvalid', '2': 10},
|
||||
const {'1': 'DocViewIdInvalid', '2': 11},
|
||||
const {'1': 'DocDescTooLong', '2': 12},
|
||||
const {'1': 'DocFileError', '2': 13},
|
||||
],
|
||||
};
|
||||
|
||||
/// Descriptor for `EditorErrorCode`. Decode as a `google.protobuf.EnumDescriptorProto`.
|
||||
final $typed_data.Uint8List editorErrorCodeDescriptor = $convert.base64Decode('Cg9FZGl0b3JFcnJvckNvZGUSCwoHVW5rbm93bhAAEhkKFUVkaXRvckRCSW50ZXJuYWxFcnJvchABEhIKDkRvY05hbWVJbnZhbGlkEAoSFAoQRG9jVmlld0lkSW52YWxpZBAL');
|
||||
final $typed_data.Uint8List editorErrorCodeDescriptor = $convert.base64Decode('Cg9FZGl0b3JFcnJvckNvZGUSCwoHVW5rbm93bhAAEhkKFUVkaXRvckRCSW50ZXJuYWxFcnJvchABEhYKEkVkaXRvckRCQ29ubkZhaWxlZBACEhIKDkRvY05hbWVJbnZhbGlkEAoSFAoQRG9jVmlld0lkSW52YWxpZBALEhIKDkRvY0Rlc2NUb29Mb25nEAwSEAoMRG9jRmlsZUVycm9yEA0=');
|
||||
@$core.Deprecated('Use editorErrorDescriptor instead')
|
||||
const EditorError$json = const {
|
||||
'1': 'EditorError',
|
||||
|
@ -11,9 +11,13 @@ 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 EditorEvent UpdateDoc = EditorEvent._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UpdateDoc');
|
||||
static const EditorEvent ReadDoc = EditorEvent._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ReadDoc');
|
||||
|
||||
static const $core.List<EditorEvent> values = <EditorEvent> [
|
||||
CreateDoc,
|
||||
UpdateDoc,
|
||||
ReadDoc,
|
||||
];
|
||||
|
||||
static final $core.Map<$core.int, EditorEvent> _byValue = $pb.ProtobufEnum.initByValue(values);
|
||||
|
@ -13,8 +13,10 @@ const EditorEvent$json = const {
|
||||
'1': 'EditorEvent',
|
||||
'2': const [
|
||||
const {'1': 'CreateDoc', '2': 0},
|
||||
const {'1': 'UpdateDoc', '2': 1},
|
||||
const {'1': 'ReadDoc', '2': 2},
|
||||
],
|
||||
};
|
||||
|
||||
/// Descriptor for `EditorEvent`. Decode as a `google.protobuf.EnumDescriptorProto`.
|
||||
final $typed_data.Uint8List editorEventDescriptor = $convert.base64Decode('CgtFZGl0b3JFdmVudBINCglDcmVhdGVEb2MQAA==');
|
||||
final $typed_data.Uint8List editorEventDescriptor = $convert.base64Decode('CgtFZGl0b3JFdmVudBINCglDcmVhdGVEb2MQABINCglVcGRhdGVEb2MQARILCgdSZWFkRG9jEAI=');
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Auto-generated, do not edit
|
||||
export './doc_modify.pb.dart';
|
||||
export './doc_create.pb.dart';
|
||||
export './errors.pb.dart';
|
||||
export './event.pb.dart';
|
||||
|
@ -18,8 +18,10 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
|
||||
"ObservableSubject"
|
||||
| "KeyValue"
|
||||
| "CreateDocRequest"
|
||||
| "DocDescription"
|
||||
| "Doc"
|
||||
| "QueryDocRequest"
|
||||
| "UpdateDocRequest"
|
||||
| "EditorError"
|
||||
| "QueryAppRequest"
|
||||
| "CreateAppRequest"
|
||||
|
@ -15,6 +15,9 @@ flowy-infra = { path = "../flowy-infra" }
|
||||
diesel = {version = "1.4.7", features = ["sqlite"]}
|
||||
diesel_derives = {version = "1.4.1", features = ["sqlite"]}
|
||||
protobuf = {version = "2.18.0"}
|
||||
unicode-segmentation = "1.7.1"
|
||||
lazy_static = "1.4.0"
|
||||
log = "0.4.14"
|
||||
|
||||
[dev-dependencies]
|
||||
flowy-test = { path = "../flowy-test" }
|
@ -8,7 +8,7 @@ use std::convert::TryInto;
|
||||
#[derive(ProtoBuf, Default)]
|
||||
pub struct CreateDocRequest {
|
||||
#[pb(index = 1)]
|
||||
id: String,
|
||||
pub id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub name: String,
|
||||
@ -52,7 +52,7 @@ impl TryInto<CreateDocParams> for CreateDocRequest {
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default, Debug)]
|
||||
pub struct Doc {
|
||||
pub struct DocDescription {
|
||||
#[pb(index = 1)]
|
||||
pub id: String,
|
||||
|
||||
@ -64,7 +64,13 @@ pub struct Doc {
|
||||
|
||||
#[pb(index = 4)]
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
#[pb(index = 5)]
|
||||
#[derive(ProtoBuf, Default, Debug)]
|
||||
pub struct Doc {
|
||||
#[pb(index = 1)]
|
||||
pub desc: DocDescription,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub content: String,
|
||||
}
|
||||
|
@ -1,5 +1,72 @@
|
||||
use crate::{entities::doc::parser::*, errors::*};
|
||||
use flowy_derive::ProtoBuf;
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[derive(ProtoBuf, Default)]
|
||||
pub struct UpdateDocRequest {
|
||||
#[pb(index = 1)]
|
||||
pub id: String,
|
||||
|
||||
#[pb(index = 2, one_of)]
|
||||
pub name: Option<String>,
|
||||
|
||||
#[pb(index = 3, one_of)]
|
||||
pub desc: Option<String>,
|
||||
|
||||
#[pb(index = 4, one_of)]
|
||||
pub content: Option<String>,
|
||||
}
|
||||
|
||||
pub(crate) struct UpdateDocParams {
|
||||
pub(crate) id: String,
|
||||
pub(crate) name: Option<String>,
|
||||
pub(crate) desc: Option<String>,
|
||||
pub(crate) content: Option<String>,
|
||||
}
|
||||
|
||||
impl TryInto<UpdateDocParams> for UpdateDocRequest {
|
||||
type Error = EditorError;
|
||||
|
||||
fn try_into(self) -> Result<UpdateDocParams, Self::Error> {
|
||||
let id = DocId::parse(self.id)
|
||||
.map_err(|e| {
|
||||
ErrorBuilder::new(EditorErrorCode::DocViewIdInvalid)
|
||||
.msg(e)
|
||||
.build()
|
||||
})?
|
||||
.0;
|
||||
|
||||
let name = match self.name {
|
||||
None => None,
|
||||
Some(name) => Some(
|
||||
DocName::parse(name)
|
||||
.map_err(|e| {
|
||||
ErrorBuilder::new(EditorErrorCode::DocNameInvalid)
|
||||
.msg(e)
|
||||
.build()
|
||||
})?
|
||||
.0,
|
||||
),
|
||||
};
|
||||
|
||||
let desc = match self.desc {
|
||||
None => None,
|
||||
Some(desc) => Some(
|
||||
DocDesc::parse(desc)
|
||||
.map_err(|e| {
|
||||
ErrorBuilder::new(EditorErrorCode::DocDescTooLong)
|
||||
.msg(e)
|
||||
.build()
|
||||
})?
|
||||
.0,
|
||||
),
|
||||
};
|
||||
|
||||
Ok(UpdateDocParams {
|
||||
id,
|
||||
name,
|
||||
desc,
|
||||
content: self.content,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -6,14 +6,10 @@ use std::convert::TryInto;
|
||||
pub struct QueryDocRequest {
|
||||
#[pb(index = 1)]
|
||||
pub doc_id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub read_content: bool,
|
||||
}
|
||||
|
||||
pub struct QueryDocParams {
|
||||
pub(crate) struct QueryDocParams {
|
||||
pub doc_id: String,
|
||||
pub read_content: bool,
|
||||
}
|
||||
|
||||
impl TryInto<QueryDocParams> for QueryDocRequest {
|
||||
@ -28,9 +24,6 @@ impl TryInto<QueryDocParams> for QueryDocRequest {
|
||||
})?
|
||||
.0;
|
||||
|
||||
Ok(QueryDocParams {
|
||||
doc_id,
|
||||
read_content: self.read_content,
|
||||
})
|
||||
Ok(QueryDocParams { doc_id })
|
||||
}
|
||||
}
|
||||
|
14
rust-lib/flowy-editor/src/entities/doc/parser/doc_desc.rs
Normal file
14
rust-lib/flowy-editor/src/entities/doc/parser/doc_desc.rs
Normal file
@ -0,0 +1,14 @@
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DocDesc(pub String);
|
||||
|
||||
impl DocDesc {
|
||||
pub fn parse(s: String) -> Result<DocDesc, String> {
|
||||
if s.graphemes(true).count() > 1000 {
|
||||
return Err(format!("Doc desc too long"));
|
||||
}
|
||||
|
||||
Ok(Self(s))
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
mod doc_desc;
|
||||
mod doc_id;
|
||||
mod doc_name;
|
||||
mod doc_view_id;
|
||||
|
||||
pub use doc_desc::*;
|
||||
pub use doc_id::*;
|
||||
pub use doc_name::*;
|
||||
pub use doc_view_id::*;
|
||||
|
@ -1,3 +1,4 @@
|
||||
use crate::services::file_manager::FileError;
|
||||
use derive_more::Display;
|
||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||
use flowy_dispatch::prelude::{EventResponse, ResponseBuilder};
|
||||
@ -24,16 +25,25 @@ impl EditorError {
|
||||
#[derive(Debug, Clone, ProtoBuf_Enum, Display, PartialEq, Eq)]
|
||||
pub enum EditorErrorCode {
|
||||
#[display(fmt = "Unknown")]
|
||||
Unknown = 0,
|
||||
Unknown = 0,
|
||||
|
||||
#[display(fmt = "EditorDBInternalError")]
|
||||
EditorDBInternalError = 1,
|
||||
|
||||
#[display(fmt = "EditorDBConnFailed")]
|
||||
EditorDBConnFailed = 2,
|
||||
|
||||
#[display(fmt = "DocNameInvalid")]
|
||||
DocNameInvalid = 10,
|
||||
DocNameInvalid = 10,
|
||||
|
||||
#[display(fmt = "DocViewIdInvalid")]
|
||||
DocViewIdInvalid = 11,
|
||||
DocViewIdInvalid = 11,
|
||||
|
||||
#[display(fmt = "DocDescTooLong")]
|
||||
DocDescTooLong = 12,
|
||||
|
||||
#[display(fmt = "DocDescTooLong")]
|
||||
DocFileError = 13,
|
||||
}
|
||||
|
||||
impl std::default::Default for EditorErrorCode {
|
||||
@ -48,6 +58,14 @@ impl std::convert::From<flowy_database::result::Error> for EditorError {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<FileError> for EditorError {
|
||||
fn from(error: FileError) -> Self {
|
||||
ErrorBuilder::new(EditorErrorCode::DocFileError)
|
||||
.error(error)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
impl flowy_dispatch::Error for EditorError {
|
||||
fn as_response(&self) -> EventResponse {
|
||||
let bytes: Vec<u8> = self.clone().try_into().unwrap();
|
||||
|
@ -5,6 +5,14 @@ use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
|
||||
#[event_err = "EditorError"]
|
||||
pub enum EditorEvent {
|
||||
#[display(fmt = "CreateDoc")]
|
||||
#[event(input = "CreateDocRequest", output = "Doc")]
|
||||
#[event(input = "CreateDocRequest", output = "DocDescription")]
|
||||
CreateDoc = 0,
|
||||
|
||||
#[display(fmt = "UpdateDoc")]
|
||||
#[event(input = "UpdateDocRequest")]
|
||||
UpdateDoc = 1,
|
||||
|
||||
#[display(fmt = "ReadDoc")]
|
||||
#[event(input = "QueryDocRequest", output = "Doc")]
|
||||
ReadDoc = 2,
|
||||
}
|
||||
|
@ -1,18 +1,65 @@
|
||||
use crate::{entities::doc::*, errors::EditorError, services::file_manager::FileManager};
|
||||
use crate::{
|
||||
entities::doc::*,
|
||||
errors::EditorError,
|
||||
services::{doc_controller::DocController, file_manager::FileManager},
|
||||
};
|
||||
use flowy_dispatch::prelude::*;
|
||||
use std::{
|
||||
convert::TryInto,
|
||||
path::Path,
|
||||
sync::{Arc, RwLock},
|
||||
};
|
||||
|
||||
pub async fn create_doc(
|
||||
data: Data<CreateDocRequest>,
|
||||
controller: ModuleData<DocController>,
|
||||
manager: ModuleData<RwLock<FileManager>>,
|
||||
) -> ResponseResult<DocDescription, EditorError> {
|
||||
let params: CreateDocParams = data.into_inner().try_into()?;
|
||||
let path = manager.read().unwrap().make_file_path(¶ms.id);
|
||||
let doc_desc = controller
|
||||
.create_doc(params, path.to_str().unwrap())
|
||||
.await?;
|
||||
response_ok(doc_desc)
|
||||
}
|
||||
|
||||
pub async fn read_doc(
|
||||
data: Data<QueryDocRequest>,
|
||||
controller: ModuleData<DocController>,
|
||||
manager: ModuleData<RwLock<FileManager>>,
|
||||
) -> ResponseResult<Doc, EditorError> {
|
||||
let params: CreateDocParams = data.into_inner().try_into()?;
|
||||
// let user = session.sign_in(params).await?;
|
||||
// let user_detail = UserDetail::from(user);
|
||||
// response_ok(user_detail)
|
||||
let params: QueryDocParams = data.into_inner().try_into()?;
|
||||
let desc = controller.read_doc(¶ms.doc_id).await?;
|
||||
|
||||
panic!()
|
||||
let content = manager
|
||||
.write()
|
||||
.unwrap()
|
||||
.open(Path::new(&desc.path), desc.id.clone())?;
|
||||
|
||||
let doc = Doc { desc, content };
|
||||
response_ok(doc)
|
||||
}
|
||||
|
||||
pub async fn update_doc(
|
||||
data: Data<UpdateDocRequest>,
|
||||
controller: ModuleData<DocController>,
|
||||
manager: ModuleData<RwLock<FileManager>>,
|
||||
) -> Result<(), EditorError> {
|
||||
let mut params: UpdateDocParams = data.into_inner().try_into()?;
|
||||
match params.content.take() {
|
||||
None => {},
|
||||
Some(s) => {
|
||||
let doc_desc = controller.read_doc(¶ms.id).await?;
|
||||
manager
|
||||
.write()
|
||||
.unwrap()
|
||||
.save(Path::new(&doc_desc.path), &s, params.id.clone());
|
||||
},
|
||||
}
|
||||
|
||||
if params.name.is_some() || params.desc.is_some() {
|
||||
let _ = controller.update_doc(params).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
mod entities;
|
||||
mod errors;
|
||||
mod event;
|
||||
pub mod entities;
|
||||
pub mod errors;
|
||||
pub mod event;
|
||||
mod handlers;
|
||||
pub mod module;
|
||||
mod protobuf;
|
||||
|
@ -2,7 +2,10 @@ use crate::{
|
||||
errors::EditorError,
|
||||
event::EditorEvent,
|
||||
handlers::*,
|
||||
services::file_manager::FileManager,
|
||||
services::{
|
||||
doc_controller::DocController,
|
||||
file_manager::{FileManager, FileManagerConfig},
|
||||
},
|
||||
};
|
||||
use flowy_database::DBConnection;
|
||||
use flowy_dispatch::prelude::*;
|
||||
@ -12,11 +15,27 @@ pub trait EditorDatabase: Send + Sync {
|
||||
fn db_connection(&self) -> Result<DBConnection, EditorError>;
|
||||
}
|
||||
|
||||
pub fn create() -> Module {
|
||||
let file_manager = RwLock::new(FileManager::new());
|
||||
pub struct EditorConfig {
|
||||
root: String,
|
||||
}
|
||||
|
||||
impl EditorConfig {
|
||||
pub fn new(root: &str) -> Self {
|
||||
Self {
|
||||
root: root.to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create(database: Arc<dyn EditorDatabase>, config: EditorConfig) -> Module {
|
||||
let file_manager = RwLock::new(FileManager::new(FileManagerConfig::new(&config.root)));
|
||||
let doc_controller = DocController::new(database);
|
||||
|
||||
Module::new()
|
||||
.name("Flowy-Editor")
|
||||
.data(file_manager)
|
||||
.data(doc_controller)
|
||||
.event(EditorEvent::CreateDoc, create_doc)
|
||||
.event(EditorEvent::UpdateDoc, update_doc)
|
||||
.event(EditorEvent::ReadDoc, read_doc)
|
||||
}
|
||||
|
@ -267,26 +267,25 @@ impl ::protobuf::reflect::ProtobufValue for CreateDocRequest {
|
||||
}
|
||||
|
||||
#[derive(PartialEq,Clone,Default)]
|
||||
pub struct Doc {
|
||||
pub struct DocDescription {
|
||||
// message fields
|
||||
pub id: ::std::string::String,
|
||||
pub name: ::std::string::String,
|
||||
pub desc: ::std::string::String,
|
||||
pub path: ::std::string::String,
|
||||
pub content: ::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<'a> ::std::default::Default for &'a DocDescription {
|
||||
fn default() -> &'a DocDescription {
|
||||
<DocDescription as ::protobuf::Message>::default_instance()
|
||||
}
|
||||
}
|
||||
|
||||
impl Doc {
|
||||
pub fn new() -> Doc {
|
||||
impl DocDescription {
|
||||
pub fn new() -> DocDescription {
|
||||
::std::default::Default::default()
|
||||
}
|
||||
|
||||
@ -393,8 +392,220 @@ impl Doc {
|
||||
pub fn take_path(&mut self) -> ::std::string::String {
|
||||
::std::mem::replace(&mut self.path, ::std::string::String::new())
|
||||
}
|
||||
}
|
||||
|
||||
// string content = 5;
|
||||
impl ::protobuf::Message for DocDescription {
|
||||
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.desc)?;
|
||||
},
|
||||
4 => {
|
||||
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.path)?;
|
||||
},
|
||||
_ => {
|
||||
::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.desc.is_empty() {
|
||||
my_size += ::protobuf::rt::string_size(3, &self.desc);
|
||||
}
|
||||
if !self.path.is_empty() {
|
||||
my_size += ::protobuf::rt::string_size(4, &self.path);
|
||||
}
|
||||
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.desc.is_empty() {
|
||||
os.write_string(3, &self.desc)?;
|
||||
}
|
||||
if !self.path.is_empty() {
|
||||
os.write_string(4, &self.path)?;
|
||||
}
|
||||
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() -> DocDescription {
|
||||
DocDescription::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: &DocDescription| { &m.id },
|
||||
|m: &mut DocDescription| { &mut m.id },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"name",
|
||||
|m: &DocDescription| { &m.name },
|
||||
|m: &mut DocDescription| { &mut m.name },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"desc",
|
||||
|m: &DocDescription| { &m.desc },
|
||||
|m: &mut DocDescription| { &mut m.desc },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"path",
|
||||
|m: &DocDescription| { &m.path },
|
||||
|m: &mut DocDescription| { &mut m.path },
|
||||
));
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<DocDescription>(
|
||||
"DocDescription",
|
||||
fields,
|
||||
file_descriptor_proto()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn default_instance() -> &'static DocDescription {
|
||||
static instance: ::protobuf::rt::LazyV2<DocDescription> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(DocDescription::new)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Clear for DocDescription {
|
||||
fn clear(&mut self) {
|
||||
self.id.clear();
|
||||
self.name.clear();
|
||||
self.desc.clear();
|
||||
self.path.clear();
|
||||
self.unknown_fields.clear();
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for DocDescription {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
::protobuf::text_format::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::reflect::ProtobufValue for DocDescription {
|
||||
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
||||
::protobuf::reflect::ReflectValueRef::Message(self)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq,Clone,Default)]
|
||||
pub struct Doc {
|
||||
// message fields
|
||||
pub desc: ::protobuf::SingularPtrField<DocDescription>,
|
||||
pub content: ::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()
|
||||
}
|
||||
|
||||
// .DocDescription desc = 1;
|
||||
|
||||
|
||||
pub fn get_desc(&self) -> &DocDescription {
|
||||
self.desc.as_ref().unwrap_or_else(|| <DocDescription as ::protobuf::Message>::default_instance())
|
||||
}
|
||||
pub fn clear_desc(&mut self) {
|
||||
self.desc.clear();
|
||||
}
|
||||
|
||||
pub fn has_desc(&self) -> bool {
|
||||
self.desc.is_some()
|
||||
}
|
||||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_desc(&mut self, v: DocDescription) {
|
||||
self.desc = ::protobuf::SingularPtrField::some(v);
|
||||
}
|
||||
|
||||
// Mutable pointer to the field.
|
||||
// If field is not initialized, it is initialized with default value first.
|
||||
pub fn mut_desc(&mut self) -> &mut DocDescription {
|
||||
if self.desc.is_none() {
|
||||
self.desc.set_default();
|
||||
}
|
||||
self.desc.as_mut().unwrap()
|
||||
}
|
||||
|
||||
// Take field
|
||||
pub fn take_desc(&mut self) -> DocDescription {
|
||||
self.desc.take().unwrap_or_else(|| DocDescription::new())
|
||||
}
|
||||
|
||||
// string content = 2;
|
||||
|
||||
|
||||
pub fn get_content(&self) -> &str {
|
||||
@ -423,6 +634,11 @@ impl Doc {
|
||||
|
||||
impl ::protobuf::Message for Doc {
|
||||
fn is_initialized(&self) -> bool {
|
||||
for v in &self.desc {
|
||||
if !v.is_initialized() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
true
|
||||
}
|
||||
|
||||
@ -431,18 +647,9 @@ impl ::protobuf::Message for Doc {
|
||||
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)?;
|
||||
::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.desc)?;
|
||||
},
|
||||
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.desc)?;
|
||||
},
|
||||
4 => {
|
||||
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.path)?;
|
||||
},
|
||||
5 => {
|
||||
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.content)?;
|
||||
},
|
||||
_ => {
|
||||
@ -457,20 +664,12 @@ impl ::protobuf::Message for Doc {
|
||||
#[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.desc.is_empty() {
|
||||
my_size += ::protobuf::rt::string_size(3, &self.desc);
|
||||
}
|
||||
if !self.path.is_empty() {
|
||||
my_size += ::protobuf::rt::string_size(4, &self.path);
|
||||
if let Some(ref v) = self.desc.as_ref() {
|
||||
let len = v.compute_size();
|
||||
my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len;
|
||||
}
|
||||
if !self.content.is_empty() {
|
||||
my_size += ::protobuf::rt::string_size(5, &self.content);
|
||||
my_size += ::protobuf::rt::string_size(2, &self.content);
|
||||
}
|
||||
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
|
||||
self.cached_size.set(my_size);
|
||||
@ -478,20 +677,13 @@ impl ::protobuf::Message for Doc {
|
||||
}
|
||||
|
||||
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.desc.is_empty() {
|
||||
os.write_string(3, &self.desc)?;
|
||||
}
|
||||
if !self.path.is_empty() {
|
||||
os.write_string(4, &self.path)?;
|
||||
if let Some(ref v) = self.desc.as_ref() {
|
||||
os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?;
|
||||
os.write_raw_varint32(v.get_cached_size())?;
|
||||
v.write_to_with_cached_sizes(os)?;
|
||||
}
|
||||
if !self.content.is_empty() {
|
||||
os.write_string(5, &self.content)?;
|
||||
os.write_string(2, &self.content)?;
|
||||
}
|
||||
os.write_unknown_fields(self.get_unknown_fields())?;
|
||||
::std::result::Result::Ok(())
|
||||
@ -531,26 +723,11 @@ impl ::protobuf::Message for Doc {
|
||||
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>(
|
||||
fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<DocDescription>>(
|
||||
"desc",
|
||||
|m: &Doc| { &m.desc },
|
||||
|m: &mut Doc| { &mut m.desc },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"path",
|
||||
|m: &Doc| { &m.path },
|
||||
|m: &mut Doc| { &mut m.path },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"content",
|
||||
|m: &Doc| { &m.content },
|
||||
@ -572,10 +749,7 @@ impl ::protobuf::Message for Doc {
|
||||
|
||||
impl ::protobuf::Clear for Doc {
|
||||
fn clear(&mut self) {
|
||||
self.id.clear();
|
||||
self.name.clear();
|
||||
self.desc.clear();
|
||||
self.path.clear();
|
||||
self.content.clear();
|
||||
self.unknown_fields.clear();
|
||||
}
|
||||
@ -596,36 +770,41 @@ impl ::protobuf::reflect::ProtobufValue for Doc {
|
||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
\n\x10doc_create.proto\"J\n\x10CreateDocRequest\x12\x0e\n\x02id\x18\x01\
|
||||
\x20\x01(\tR\x02id\x12\x12\n\x04name\x18\x02\x20\x01(\tR\x04name\x12\x12\
|
||||
\n\x04desc\x18\x03\x20\x01(\tR\x04desc\"k\n\x03Doc\x12\x0e\n\x02id\x18\
|
||||
\x01\x20\x01(\tR\x02id\x12\x12\n\x04name\x18\x02\x20\x01(\tR\x04name\x12\
|
||||
\x12\n\x04desc\x18\x03\x20\x01(\tR\x04desc\x12\x12\n\x04path\x18\x04\x20\
|
||||
\x01(\tR\x04path\x12\x18\n\x07content\x18\x05\x20\x01(\tR\x07contentJ\
|
||||
\xfa\x03\n\x06\x12\x04\0\0\r\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\
|
||||
\x02\x04\0\x12\x04\x02\0\x06\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\x12\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\r\n\x0c\n\
|
||||
\x05\x04\0\x02\0\x03\x12\x03\x03\x10\x11\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\x0b\n\x04\x04\0\x02\x02\x12\x03\x05\x04\x14\n\x0c\
|
||||
\n\x05\x04\0\x02\x02\x05\x12\x03\x05\x04\n\n\x0c\n\x05\x04\0\x02\x02\x01\
|
||||
\x12\x03\x05\x0b\x0f\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x05\x12\x13\n\
|
||||
\n\n\x02\x04\x01\x12\x04\x07\0\r\x01\n\n\n\x03\x04\x01\x01\x12\x03\x07\
|
||||
\x08\x0b\n\x0b\n\x04\x04\x01\x02\0\x12\x03\x08\x04\x12\n\x0c\n\x05\x04\
|
||||
\x01\x02\0\x05\x12\x03\x08\x04\n\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03\
|
||||
\x08\x0b\r\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\x08\x10\x11\n\x0b\n\x04\
|
||||
\x04\x01\x02\x01\x12\x03\t\x04\x14\n\x0c\n\x05\x04\x01\x02\x01\x05\x12\
|
||||
\x03\t\x04\n\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\t\x0b\x0f\n\x0c\n\
|
||||
\x05\x04\x01\x02\x01\x03\x12\x03\t\x12\x13\n\x0b\n\x04\x04\x01\x02\x02\
|
||||
\x12\x03\n\x04\x14\n\x0c\n\x05\x04\x01\x02\x02\x05\x12\x03\n\x04\n\n\x0c\
|
||||
\n\x05\x04\x01\x02\x02\x01\x12\x03\n\x0b\x0f\n\x0c\n\x05\x04\x01\x02\x02\
|
||||
\x03\x12\x03\n\x12\x13\n\x0b\n\x04\x04\x01\x02\x03\x12\x03\x0b\x04\x14\n\
|
||||
\x0c\n\x05\x04\x01\x02\x03\x05\x12\x03\x0b\x04\n\n\x0c\n\x05\x04\x01\x02\
|
||||
\x03\x01\x12\x03\x0b\x0b\x0f\n\x0c\n\x05\x04\x01\x02\x03\x03\x12\x03\x0b\
|
||||
\x12\x13\n\x0b\n\x04\x04\x01\x02\x04\x12\x03\x0c\x04\x17\n\x0c\n\x05\x04\
|
||||
\x01\x02\x04\x05\x12\x03\x0c\x04\n\n\x0c\n\x05\x04\x01\x02\x04\x01\x12\
|
||||
\x03\x0c\x0b\x12\n\x0c\n\x05\x04\x01\x02\x04\x03\x12\x03\x0c\x15\x16b\
|
||||
\x06proto3\
|
||||
\n\x04desc\x18\x03\x20\x01(\tR\x04desc\"\\\n\x0eDocDescription\x12\x0e\n\
|
||||
\x02id\x18\x01\x20\x01(\tR\x02id\x12\x12\n\x04name\x18\x02\x20\x01(\tR\
|
||||
\x04name\x12\x12\n\x04desc\x18\x03\x20\x01(\tR\x04desc\x12\x12\n\x04path\
|
||||
\x18\x04\x20\x01(\tR\x04path\"D\n\x03Doc\x12#\n\x04desc\x18\x01\x20\x01(\
|
||||
\x0b2\x0f.DocDescriptionR\x04desc\x12\x18\n\x07content\x18\x02\x20\x01(\
|
||||
\tR\x07contentJ\xc9\x04\n\x06\x12\x04\0\0\x10\x01\n\x08\n\x01\x0c\x12\
|
||||
\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x06\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\x12\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\r\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x10\x11\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\x0b\n\x04\x04\0\x02\x02\x12\
|
||||
\x03\x05\x04\x14\n\x0c\n\x05\x04\0\x02\x02\x05\x12\x03\x05\x04\n\n\x0c\n\
|
||||
\x05\x04\0\x02\x02\x01\x12\x03\x05\x0b\x0f\n\x0c\n\x05\x04\0\x02\x02\x03\
|
||||
\x12\x03\x05\x12\x13\n\n\n\x02\x04\x01\x12\x04\x07\0\x0c\x01\n\n\n\x03\
|
||||
\x04\x01\x01\x12\x03\x07\x08\x16\n\x0b\n\x04\x04\x01\x02\0\x12\x03\x08\
|
||||
\x04\x12\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03\x08\x04\n\n\x0c\n\x05\x04\
|
||||
\x01\x02\0\x01\x12\x03\x08\x0b\r\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\
|
||||
\x08\x10\x11\n\x0b\n\x04\x04\x01\x02\x01\x12\x03\t\x04\x14\n\x0c\n\x05\
|
||||
\x04\x01\x02\x01\x05\x12\x03\t\x04\n\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\
|
||||
\x03\t\x0b\x0f\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\t\x12\x13\n\x0b\n\
|
||||
\x04\x04\x01\x02\x02\x12\x03\n\x04\x14\n\x0c\n\x05\x04\x01\x02\x02\x05\
|
||||
\x12\x03\n\x04\n\n\x0c\n\x05\x04\x01\x02\x02\x01\x12\x03\n\x0b\x0f\n\x0c\
|
||||
\n\x05\x04\x01\x02\x02\x03\x12\x03\n\x12\x13\n\x0b\n\x04\x04\x01\x02\x03\
|
||||
\x12\x03\x0b\x04\x14\n\x0c\n\x05\x04\x01\x02\x03\x05\x12\x03\x0b\x04\n\n\
|
||||
\x0c\n\x05\x04\x01\x02\x03\x01\x12\x03\x0b\x0b\x0f\n\x0c\n\x05\x04\x01\
|
||||
\x02\x03\x03\x12\x03\x0b\x12\x13\n\n\n\x02\x04\x02\x12\x04\r\0\x10\x01\n\
|
||||
\n\n\x03\x04\x02\x01\x12\x03\r\x08\x0b\n\x0b\n\x04\x04\x02\x02\0\x12\x03\
|
||||
\x0e\x04\x1c\n\x0c\n\x05\x04\x02\x02\0\x06\x12\x03\x0e\x04\x12\n\x0c\n\
|
||||
\x05\x04\x02\x02\0\x01\x12\x03\x0e\x13\x17\n\x0c\n\x05\x04\x02\x02\0\x03\
|
||||
\x12\x03\x0e\x1a\x1b\n\x0b\n\x04\x04\x02\x02\x01\x12\x03\x0f\x04\x17\n\
|
||||
\x0c\n\x05\x04\x02\x02\x01\x05\x12\x03\x0f\x04\n\n\x0c\n\x05\x04\x02\x02\
|
||||
\x01\x01\x12\x03\x0f\x0b\x12\n\x0c\n\x05\x04\x02\x02\x01\x03\x12\x03\x0f\
|
||||
\x15\x16b\x06proto3\
|
||||
";
|
||||
|
||||
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
||||
|
463
rust-lib/flowy-editor/src/protobuf/model/doc_modify.rs
Normal file
463
rust-lib/flowy-editor/src/protobuf/model/doc_modify.rs
Normal file
@ -0,0 +1,463 @@
|
||||
// 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_modify.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 UpdateDocRequest {
|
||||
// message fields
|
||||
pub id: ::std::string::String,
|
||||
// message oneof groups
|
||||
pub one_of_name: ::std::option::Option<UpdateDocRequest_oneof_one_of_name>,
|
||||
pub one_of_desc: ::std::option::Option<UpdateDocRequest_oneof_one_of_desc>,
|
||||
pub one_of_content: ::std::option::Option<UpdateDocRequest_oneof_one_of_content>,
|
||||
// special fields
|
||||
pub unknown_fields: ::protobuf::UnknownFields,
|
||||
pub cached_size: ::protobuf::CachedSize,
|
||||
}
|
||||
|
||||
impl<'a> ::std::default::Default for &'a UpdateDocRequest {
|
||||
fn default() -> &'a UpdateDocRequest {
|
||||
<UpdateDocRequest as ::protobuf::Message>::default_instance()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone,PartialEq,Debug)]
|
||||
pub enum UpdateDocRequest_oneof_one_of_name {
|
||||
name(::std::string::String),
|
||||
}
|
||||
|
||||
#[derive(Clone,PartialEq,Debug)]
|
||||
pub enum UpdateDocRequest_oneof_one_of_desc {
|
||||
desc(::std::string::String),
|
||||
}
|
||||
|
||||
#[derive(Clone,PartialEq,Debug)]
|
||||
pub enum UpdateDocRequest_oneof_one_of_content {
|
||||
content(::std::string::String),
|
||||
}
|
||||
|
||||
impl UpdateDocRequest {
|
||||
pub fn new() -> UpdateDocRequest {
|
||||
::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 {
|
||||
match self.one_of_name {
|
||||
::std::option::Option::Some(UpdateDocRequest_oneof_one_of_name::name(ref v)) => v,
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
pub fn clear_name(&mut self) {
|
||||
self.one_of_name = ::std::option::Option::None;
|
||||
}
|
||||
|
||||
pub fn has_name(&self) -> bool {
|
||||
match self.one_of_name {
|
||||
::std::option::Option::Some(UpdateDocRequest_oneof_one_of_name::name(..)) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_name(&mut self, v: ::std::string::String) {
|
||||
self.one_of_name = ::std::option::Option::Some(UpdateDocRequest_oneof_one_of_name::name(v))
|
||||
}
|
||||
|
||||
// Mutable pointer to the field.
|
||||
pub fn mut_name(&mut self) -> &mut ::std::string::String {
|
||||
if let ::std::option::Option::Some(UpdateDocRequest_oneof_one_of_name::name(_)) = self.one_of_name {
|
||||
} else {
|
||||
self.one_of_name = ::std::option::Option::Some(UpdateDocRequest_oneof_one_of_name::name(::std::string::String::new()));
|
||||
}
|
||||
match self.one_of_name {
|
||||
::std::option::Option::Some(UpdateDocRequest_oneof_one_of_name::name(ref mut v)) => v,
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
// Take field
|
||||
pub fn take_name(&mut self) -> ::std::string::String {
|
||||
if self.has_name() {
|
||||
match self.one_of_name.take() {
|
||||
::std::option::Option::Some(UpdateDocRequest_oneof_one_of_name::name(v)) => v,
|
||||
_ => panic!(),
|
||||
}
|
||||
} else {
|
||||
::std::string::String::new()
|
||||
}
|
||||
}
|
||||
|
||||
// string desc = 3;
|
||||
|
||||
|
||||
pub fn get_desc(&self) -> &str {
|
||||
match self.one_of_desc {
|
||||
::std::option::Option::Some(UpdateDocRequest_oneof_one_of_desc::desc(ref v)) => v,
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
pub fn clear_desc(&mut self) {
|
||||
self.one_of_desc = ::std::option::Option::None;
|
||||
}
|
||||
|
||||
pub fn has_desc(&self) -> bool {
|
||||
match self.one_of_desc {
|
||||
::std::option::Option::Some(UpdateDocRequest_oneof_one_of_desc::desc(..)) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_desc(&mut self, v: ::std::string::String) {
|
||||
self.one_of_desc = ::std::option::Option::Some(UpdateDocRequest_oneof_one_of_desc::desc(v))
|
||||
}
|
||||
|
||||
// Mutable pointer to the field.
|
||||
pub fn mut_desc(&mut self) -> &mut ::std::string::String {
|
||||
if let ::std::option::Option::Some(UpdateDocRequest_oneof_one_of_desc::desc(_)) = self.one_of_desc {
|
||||
} else {
|
||||
self.one_of_desc = ::std::option::Option::Some(UpdateDocRequest_oneof_one_of_desc::desc(::std::string::String::new()));
|
||||
}
|
||||
match self.one_of_desc {
|
||||
::std::option::Option::Some(UpdateDocRequest_oneof_one_of_desc::desc(ref mut v)) => v,
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
// Take field
|
||||
pub fn take_desc(&mut self) -> ::std::string::String {
|
||||
if self.has_desc() {
|
||||
match self.one_of_desc.take() {
|
||||
::std::option::Option::Some(UpdateDocRequest_oneof_one_of_desc::desc(v)) => v,
|
||||
_ => panic!(),
|
||||
}
|
||||
} else {
|
||||
::std::string::String::new()
|
||||
}
|
||||
}
|
||||
|
||||
// string content = 4;
|
||||
|
||||
|
||||
pub fn get_content(&self) -> &str {
|
||||
match self.one_of_content {
|
||||
::std::option::Option::Some(UpdateDocRequest_oneof_one_of_content::content(ref v)) => v,
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
pub fn clear_content(&mut self) {
|
||||
self.one_of_content = ::std::option::Option::None;
|
||||
}
|
||||
|
||||
pub fn has_content(&self) -> bool {
|
||||
match self.one_of_content {
|
||||
::std::option::Option::Some(UpdateDocRequest_oneof_one_of_content::content(..)) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_content(&mut self, v: ::std::string::String) {
|
||||
self.one_of_content = ::std::option::Option::Some(UpdateDocRequest_oneof_one_of_content::content(v))
|
||||
}
|
||||
|
||||
// Mutable pointer to the field.
|
||||
pub fn mut_content(&mut self) -> &mut ::std::string::String {
|
||||
if let ::std::option::Option::Some(UpdateDocRequest_oneof_one_of_content::content(_)) = self.one_of_content {
|
||||
} else {
|
||||
self.one_of_content = ::std::option::Option::Some(UpdateDocRequest_oneof_one_of_content::content(::std::string::String::new()));
|
||||
}
|
||||
match self.one_of_content {
|
||||
::std::option::Option::Some(UpdateDocRequest_oneof_one_of_content::content(ref mut v)) => v,
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
// Take field
|
||||
pub fn take_content(&mut self) -> ::std::string::String {
|
||||
if self.has_content() {
|
||||
match self.one_of_content.take() {
|
||||
::std::option::Option::Some(UpdateDocRequest_oneof_one_of_content::content(v)) => v,
|
||||
_ => panic!(),
|
||||
}
|
||||
} else {
|
||||
::std::string::String::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Message for UpdateDocRequest {
|
||||
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 => {
|
||||
if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited {
|
||||
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
|
||||
}
|
||||
self.one_of_name = ::std::option::Option::Some(UpdateDocRequest_oneof_one_of_name::name(is.read_string()?));
|
||||
},
|
||||
3 => {
|
||||
if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited {
|
||||
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
|
||||
}
|
||||
self.one_of_desc = ::std::option::Option::Some(UpdateDocRequest_oneof_one_of_desc::desc(is.read_string()?));
|
||||
},
|
||||
4 => {
|
||||
if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited {
|
||||
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
|
||||
}
|
||||
self.one_of_content = ::std::option::Option::Some(UpdateDocRequest_oneof_one_of_content::content(is.read_string()?));
|
||||
},
|
||||
_ => {
|
||||
::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 let ::std::option::Option::Some(ref v) = self.one_of_name {
|
||||
match v {
|
||||
&UpdateDocRequest_oneof_one_of_name::name(ref v) => {
|
||||
my_size += ::protobuf::rt::string_size(2, &v);
|
||||
},
|
||||
};
|
||||
}
|
||||
if let ::std::option::Option::Some(ref v) = self.one_of_desc {
|
||||
match v {
|
||||
&UpdateDocRequest_oneof_one_of_desc::desc(ref v) => {
|
||||
my_size += ::protobuf::rt::string_size(3, &v);
|
||||
},
|
||||
};
|
||||
}
|
||||
if let ::std::option::Option::Some(ref v) = self.one_of_content {
|
||||
match v {
|
||||
&UpdateDocRequest_oneof_one_of_content::content(ref v) => {
|
||||
my_size += ::protobuf::rt::string_size(4, &v);
|
||||
},
|
||||
};
|
||||
}
|
||||
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 let ::std::option::Option::Some(ref v) = self.one_of_name {
|
||||
match v {
|
||||
&UpdateDocRequest_oneof_one_of_name::name(ref v) => {
|
||||
os.write_string(2, v)?;
|
||||
},
|
||||
};
|
||||
}
|
||||
if let ::std::option::Option::Some(ref v) = self.one_of_desc {
|
||||
match v {
|
||||
&UpdateDocRequest_oneof_one_of_desc::desc(ref v) => {
|
||||
os.write_string(3, v)?;
|
||||
},
|
||||
};
|
||||
}
|
||||
if let ::std::option::Option::Some(ref v) = self.one_of_content {
|
||||
match v {
|
||||
&UpdateDocRequest_oneof_one_of_content::content(ref v) => {
|
||||
os.write_string(4, v)?;
|
||||
},
|
||||
};
|
||||
}
|
||||
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() -> UpdateDocRequest {
|
||||
UpdateDocRequest::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: &UpdateDocRequest| { &m.id },
|
||||
|m: &mut UpdateDocRequest| { &mut m.id },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_singular_string_accessor::<_>(
|
||||
"name",
|
||||
UpdateDocRequest::has_name,
|
||||
UpdateDocRequest::get_name,
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_singular_string_accessor::<_>(
|
||||
"desc",
|
||||
UpdateDocRequest::has_desc,
|
||||
UpdateDocRequest::get_desc,
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_singular_string_accessor::<_>(
|
||||
"content",
|
||||
UpdateDocRequest::has_content,
|
||||
UpdateDocRequest::get_content,
|
||||
));
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<UpdateDocRequest>(
|
||||
"UpdateDocRequest",
|
||||
fields,
|
||||
file_descriptor_proto()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn default_instance() -> &'static UpdateDocRequest {
|
||||
static instance: ::protobuf::rt::LazyV2<UpdateDocRequest> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(UpdateDocRequest::new)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Clear for UpdateDocRequest {
|
||||
fn clear(&mut self) {
|
||||
self.id.clear();
|
||||
self.one_of_name = ::std::option::Option::None;
|
||||
self.one_of_desc = ::std::option::Option::None;
|
||||
self.one_of_content = ::std::option::Option::None;
|
||||
self.unknown_fields.clear();
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for UpdateDocRequest {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
::protobuf::text_format::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::reflect::ProtobufValue for UpdateDocRequest {
|
||||
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
||||
::protobuf::reflect::ReflectValueRef::Message(self)
|
||||
}
|
||||
}
|
||||
|
||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
\n\x10doc_modify.proto\"\x9a\x01\n\x10UpdateDocRequest\x12\x0e\n\x02id\
|
||||
\x18\x01\x20\x01(\tR\x02id\x12\x14\n\x04name\x18\x02\x20\x01(\tH\0R\x04n\
|
||||
ame\x12\x14\n\x04desc\x18\x03\x20\x01(\tH\x01R\x04desc\x12\x1a\n\x07cont\
|
||||
ent\x18\x04\x20\x01(\tH\x02R\x07contentB\r\n\x0bone_of_nameB\r\n\x0bone_\
|
||||
of_descB\x10\n\x0eone_of_contentJ\xd7\x02\n\x06\x12\x04\0\0\x07\x01\n\
|
||||
\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x07\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\x12\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\r\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x10\
|
||||
\x11\n\x0b\n\x04\x04\0\x08\0\x12\x03\x04\x04*\n\x0c\n\x05\x04\0\x08\0\
|
||||
\x01\x12\x03\x04\n\x15\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x18(\n\x0c\
|
||||
\n\x05\x04\0\x02\x01\x05\x12\x03\x04\x18\x1e\n\x0c\n\x05\x04\0\x02\x01\
|
||||
\x01\x12\x03\x04\x1f#\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04&'\n\x0b\
|
||||
\n\x04\x04\0\x08\x01\x12\x03\x05\x04*\n\x0c\n\x05\x04\0\x08\x01\x01\x12\
|
||||
\x03\x05\n\x15\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x05\x18(\n\x0c\n\x05\
|
||||
\x04\0\x02\x02\x05\x12\x03\x05\x18\x1e\n\x0c\n\x05\x04\0\x02\x02\x01\x12\
|
||||
\x03\x05\x1f#\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x05&'\n\x0b\n\x04\
|
||||
\x04\0\x08\x02\x12\x03\x06\x040\n\x0c\n\x05\x04\0\x08\x02\x01\x12\x03\
|
||||
\x06\n\x18\n\x0b\n\x04\x04\0\x02\x03\x12\x03\x06\x1b.\n\x0c\n\x05\x04\0\
|
||||
\x02\x03\x05\x12\x03\x06\x1b!\n\x0c\n\x05\x04\0\x02\x03\x01\x12\x03\x06\
|
||||
\")\n\x0c\n\x05\x04\0\x02\x03\x03\x12\x03\x06,-b\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()
|
||||
})
|
||||
}
|
@ -27,7 +27,6 @@
|
||||
pub struct QueryDocRequest {
|
||||
// message fields
|
||||
pub doc_id: ::std::string::String,
|
||||
pub read_content: bool,
|
||||
// special fields
|
||||
pub unknown_fields: ::protobuf::UnknownFields,
|
||||
pub cached_size: ::protobuf::CachedSize,
|
||||
@ -69,21 +68,6 @@ impl QueryDocRequest {
|
||||
pub fn take_doc_id(&mut self) -> ::std::string::String {
|
||||
::std::mem::replace(&mut self.doc_id, ::std::string::String::new())
|
||||
}
|
||||
|
||||
// bool read_content = 2;
|
||||
|
||||
|
||||
pub fn get_read_content(&self) -> bool {
|
||||
self.read_content
|
||||
}
|
||||
pub fn clear_read_content(&mut self) {
|
||||
self.read_content = false;
|
||||
}
|
||||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_read_content(&mut self, v: bool) {
|
||||
self.read_content = v;
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Message for QueryDocRequest {
|
||||
@ -98,13 +82,6 @@ impl ::protobuf::Message for QueryDocRequest {
|
||||
1 => {
|
||||
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.doc_id)?;
|
||||
},
|
||||
2 => {
|
||||
if wire_type != ::protobuf::wire_format::WireTypeVarint {
|
||||
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
|
||||
}
|
||||
let tmp = is.read_bool()?;
|
||||
self.read_content = tmp;
|
||||
},
|
||||
_ => {
|
||||
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
|
||||
},
|
||||
@ -120,9 +97,6 @@ impl ::protobuf::Message for QueryDocRequest {
|
||||
if !self.doc_id.is_empty() {
|
||||
my_size += ::protobuf::rt::string_size(1, &self.doc_id);
|
||||
}
|
||||
if self.read_content != false {
|
||||
my_size += 2;
|
||||
}
|
||||
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
|
||||
self.cached_size.set(my_size);
|
||||
my_size
|
||||
@ -132,9 +106,6 @@ impl ::protobuf::Message for QueryDocRequest {
|
||||
if !self.doc_id.is_empty() {
|
||||
os.write_string(1, &self.doc_id)?;
|
||||
}
|
||||
if self.read_content != false {
|
||||
os.write_bool(2, self.read_content)?;
|
||||
}
|
||||
os.write_unknown_fields(self.get_unknown_fields())?;
|
||||
::std::result::Result::Ok(())
|
||||
}
|
||||
@ -178,11 +149,6 @@ impl ::protobuf::Message for QueryDocRequest {
|
||||
|m: &QueryDocRequest| { &m.doc_id },
|
||||
|m: &mut QueryDocRequest| { &mut m.doc_id },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>(
|
||||
"read_content",
|
||||
|m: &QueryDocRequest| { &m.read_content },
|
||||
|m: &mut QueryDocRequest| { &mut m.read_content },
|
||||
));
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<QueryDocRequest>(
|
||||
"QueryDocRequest",
|
||||
fields,
|
||||
@ -200,7 +166,6 @@ impl ::protobuf::Message for QueryDocRequest {
|
||||
impl ::protobuf::Clear for QueryDocRequest {
|
||||
fn clear(&mut self) {
|
||||
self.doc_id.clear();
|
||||
self.read_content = false;
|
||||
self.unknown_fields.clear();
|
||||
}
|
||||
}
|
||||
@ -218,16 +183,13 @@ impl ::protobuf::reflect::ProtobufValue for QueryDocRequest {
|
||||
}
|
||||
|
||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
\n\x0fdoc_query.proto\"K\n\x0fQueryDocRequest\x12\x15\n\x06doc_id\x18\
|
||||
\x01\x20\x01(\tR\x05docId\x12!\n\x0cread_content\x18\x02\x20\x01(\x08R\
|
||||
\x0breadContentJ\x98\x01\n\x06\x12\x04\0\0\x05\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\x17\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x16\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\x11\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x14\x15\n\x0b\n\
|
||||
\x04\x04\0\x02\x01\x12\x03\x04\x04\x1a\n\x0c\n\x05\x04\0\x02\x01\x05\x12\
|
||||
\x03\x04\x04\x08\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\t\x15\n\x0c\n\
|
||||
\x05\x04\0\x02\x01\x03\x12\x03\x04\x18\x19b\x06proto3\
|
||||
\n\x0fdoc_query.proto\"(\n\x0fQueryDocRequest\x12\x15\n\x06doc_id\x18\
|
||||
\x01\x20\x01(\tR\x05docIdJa\n\x06\x12\x04\0\0\x04\x01\n\x08\n\x01\x0c\
|
||||
\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x04\x01\n\n\n\x03\x04\0\
|
||||
\x01\x12\x03\x02\x08\x17\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x16\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\x11\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x14\x15b\
|
||||
\x06proto3\
|
||||
";
|
||||
|
||||
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
||||
|
@ -217,8 +217,11 @@ impl ::protobuf::reflect::ProtobufValue for EditorError {
|
||||
pub enum EditorErrorCode {
|
||||
Unknown = 0,
|
||||
EditorDBInternalError = 1,
|
||||
EditorDBConnFailed = 2,
|
||||
DocNameInvalid = 10,
|
||||
DocViewIdInvalid = 11,
|
||||
DocDescTooLong = 12,
|
||||
DocFileError = 13,
|
||||
}
|
||||
|
||||
impl ::protobuf::ProtobufEnum for EditorErrorCode {
|
||||
@ -230,8 +233,11 @@ impl ::protobuf::ProtobufEnum for EditorErrorCode {
|
||||
match value {
|
||||
0 => ::std::option::Option::Some(EditorErrorCode::Unknown),
|
||||
1 => ::std::option::Option::Some(EditorErrorCode::EditorDBInternalError),
|
||||
2 => ::std::option::Option::Some(EditorErrorCode::EditorDBConnFailed),
|
||||
10 => ::std::option::Option::Some(EditorErrorCode::DocNameInvalid),
|
||||
11 => ::std::option::Option::Some(EditorErrorCode::DocViewIdInvalid),
|
||||
12 => ::std::option::Option::Some(EditorErrorCode::DocDescTooLong),
|
||||
13 => ::std::option::Option::Some(EditorErrorCode::DocFileError),
|
||||
_ => ::std::option::Option::None
|
||||
}
|
||||
}
|
||||
@ -240,8 +246,11 @@ impl ::protobuf::ProtobufEnum for EditorErrorCode {
|
||||
static values: &'static [EditorErrorCode] = &[
|
||||
EditorErrorCode::Unknown,
|
||||
EditorErrorCode::EditorDBInternalError,
|
||||
EditorErrorCode::EditorDBConnFailed,
|
||||
EditorErrorCode::DocNameInvalid,
|
||||
EditorErrorCode::DocViewIdInvalid,
|
||||
EditorErrorCode::DocDescTooLong,
|
||||
EditorErrorCode::DocFileError,
|
||||
];
|
||||
values
|
||||
}
|
||||
@ -272,26 +281,33 @@ impl ::protobuf::reflect::ProtobufValue for EditorErrorCode {
|
||||
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\
|
||||
\x03msg*\xa1\x01\n\x0fEditorErrorCode\x12\x0b\n\x07Unknown\x10\0\x12\x19\
|
||||
\n\x15EditorDBInternalError\x10\x01\x12\x16\n\x12EditorDBConnFailed\x10\
|
||||
\x02\x12\x12\n\x0eDocNameInvalid\x10\n\x12\x14\n\x10DocViewIdInvalid\x10\
|
||||
\x0b\x12\x12\n\x0eDocDescTooLong\x10\x0c\x12\x10\n\x0cDocFileError\x10\r\
|
||||
J\xcf\x03\n\x06\x12\x04\0\0\x0e\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\x0e\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\x1b\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\t\x04\x16\n\x0c\n\x05\
|
||||
\x05\0\x02\x02\x02\x12\x03\t\x19\x1a\n\x0b\n\x04\x05\0\x02\x03\x12\x03\n\
|
||||
\x04\x18\n\x0c\n\x05\x05\0\x02\x03\x01\x12\x03\n\x04\x12\n\x0c\n\x05\x05\
|
||||
\0\x02\x03\x02\x12\x03\n\x15\x17\n\x0b\n\x04\x05\0\x02\x04\x12\x03\x0b\
|
||||
\x04\x1a\n\x0c\n\x05\x05\0\x02\x04\x01\x12\x03\x0b\x04\x14\n\x0c\n\x05\
|
||||
\x05\0\x02\x04\x02\x12\x03\x0b\x17\x19\n\x0b\n\x04\x05\0\x02\x05\x12\x03\
|
||||
\x0c\x04\x18\n\x0c\n\x05\x05\0\x02\x05\x01\x12\x03\x0c\x04\x12\n\x0c\n\
|
||||
\x05\x05\0\x02\x05\x02\x12\x03\x0c\x15\x17\n\x0b\n\x04\x05\0\x02\x06\x12\
|
||||
\x03\r\x04\x16\n\x0c\n\x05\x05\0\x02\x06\x01\x12\x03\r\x04\x10\n\x0c\n\
|
||||
\x05\x05\0\x02\x06\x02\x12\x03\r\x13\x15b\x06proto3\
|
||||
";
|
||||
|
||||
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
||||
|
@ -26,6 +26,8 @@
|
||||
#[derive(Clone,PartialEq,Eq,Debug,Hash)]
|
||||
pub enum EditorEvent {
|
||||
CreateDoc = 0,
|
||||
UpdateDoc = 1,
|
||||
ReadDoc = 2,
|
||||
}
|
||||
|
||||
impl ::protobuf::ProtobufEnum for EditorEvent {
|
||||
@ -36,6 +38,8 @@ impl ::protobuf::ProtobufEnum for EditorEvent {
|
||||
fn from_i32(value: i32) -> ::std::option::Option<EditorEvent> {
|
||||
match value {
|
||||
0 => ::std::option::Option::Some(EditorEvent::CreateDoc),
|
||||
1 => ::std::option::Option::Some(EditorEvent::UpdateDoc),
|
||||
2 => ::std::option::Option::Some(EditorEvent::ReadDoc),
|
||||
_ => ::std::option::Option::None
|
||||
}
|
||||
}
|
||||
@ -43,6 +47,8 @@ impl ::protobuf::ProtobufEnum for EditorEvent {
|
||||
fn values() -> &'static [Self] {
|
||||
static values: &'static [EditorEvent] = &[
|
||||
EditorEvent::CreateDoc,
|
||||
EditorEvent::UpdateDoc,
|
||||
EditorEvent::ReadDoc,
|
||||
];
|
||||
values
|
||||
}
|
||||
@ -71,11 +77,16 @@ impl ::protobuf::reflect::ProtobufValue for EditorEvent {
|
||||
}
|
||||
|
||||
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\x04\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x05\0\x12\
|
||||
\x04\x02\0\x04\x01\n\n\n\x03\x05\0\x01\x12\x03\x02\x05\x10\n\x0b\n\x04\
|
||||
\x05\0\x02\0\x12\x03\x03\x04\x12\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x03\
|
||||
\x04\r\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x03\x10\x11b\x06proto3\
|
||||
\n\x0bevent.proto*8\n\x0bEditorEvent\x12\r\n\tCreateDoc\x10\0\x12\r\n\tU\
|
||||
pdateDoc\x10\x01\x12\x0b\n\x07ReadDoc\x10\x02J\xa5\x01\n\x06\x12\x04\0\0\
|
||||
\x06\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x05\0\x12\x04\x02\0\
|
||||
\x06\x01\n\n\n\x03\x05\0\x01\x12\x03\x02\x05\x10\n\x0b\n\x04\x05\0\x02\0\
|
||||
\x12\x03\x03\x04\x12\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x03\x04\r\n\x0c\
|
||||
\n\x05\x05\0\x02\0\x02\x12\x03\x03\x10\x11\n\x0b\n\x04\x05\0\x02\x01\x12\
|
||||
\x03\x04\x04\x12\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x04\x04\r\n\x0c\n\
|
||||
\x05\x05\0\x02\x01\x02\x12\x03\x04\x10\x11\n\x0b\n\x04\x05\0\x02\x02\x12\
|
||||
\x03\x05\x04\x10\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\x05\x04\x0b\n\x0c\
|
||||
\n\x05\x05\0\x02\x02\x02\x12\x03\x05\x0e\x0fb\x06proto3\
|
||||
";
|
||||
|
||||
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
||||
|
@ -1,5 +1,8 @@
|
||||
// Auto-generated, do not edit
|
||||
|
||||
mod doc_modify;
|
||||
pub use doc_modify::*;
|
||||
|
||||
mod doc_create;
|
||||
pub use doc_create::*;
|
||||
|
||||
|
@ -5,10 +5,13 @@ message CreateDocRequest {
|
||||
string name = 2;
|
||||
string desc = 3;
|
||||
}
|
||||
message Doc {
|
||||
message DocDescription {
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
string desc = 3;
|
||||
string path = 4;
|
||||
string content = 5;
|
||||
}
|
||||
message Doc {
|
||||
DocDescription desc = 1;
|
||||
string content = 2;
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message UpdateDocRequest {
|
||||
string id = 1;
|
||||
oneof one_of_name { string name = 2; };
|
||||
oneof one_of_desc { string desc = 3; };
|
||||
oneof one_of_content { string content = 4; };
|
||||
}
|
@ -2,5 +2,4 @@ syntax = "proto3";
|
||||
|
||||
message QueryDocRequest {
|
||||
string doc_id = 1;
|
||||
bool read_content = 2;
|
||||
}
|
||||
|
@ -7,6 +7,9 @@ message EditorError {
|
||||
enum EditorErrorCode {
|
||||
Unknown = 0;
|
||||
EditorDBInternalError = 1;
|
||||
EditorDBConnFailed = 2;
|
||||
DocNameInvalid = 10;
|
||||
DocViewIdInvalid = 11;
|
||||
DocDescTooLong = 12;
|
||||
DocFileError = 13;
|
||||
}
|
||||
|
@ -2,4 +2,6 @@ syntax = "proto3";
|
||||
|
||||
enum EditorEvent {
|
||||
CreateDoc = 0;
|
||||
UpdateDoc = 1;
|
||||
ReadDoc = 2;
|
||||
}
|
||||
|
42
rust-lib/flowy-editor/src/services/doc_controller.rs
Normal file
42
rust-lib/flowy-editor/src/services/doc_controller.rs
Normal file
@ -0,0 +1,42 @@
|
||||
use crate::{
|
||||
entities::doc::{CreateDocParams, Doc, DocDescription, QueryDocParams, UpdateDocParams},
|
||||
errors::EditorError,
|
||||
module::EditorDatabase,
|
||||
sql_tables::doc::{DocTable, DocTableChangeset, DocTableSql},
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct DocController {
|
||||
sql: Arc<DocTableSql>,
|
||||
}
|
||||
|
||||
impl DocController {
|
||||
pub(crate) fn new(database: Arc<dyn EditorDatabase>) -> Self {
|
||||
let sql = Arc::new(DocTableSql { database });
|
||||
Self { sql }
|
||||
}
|
||||
|
||||
pub(crate) async fn create_doc(
|
||||
&self,
|
||||
params: CreateDocParams,
|
||||
path: &str,
|
||||
) -> Result<DocDescription, EditorError> {
|
||||
let doc_table = DocTable::new(params, path);
|
||||
let doc: DocDescription = doc_table.clone().into();
|
||||
let _ = self.sql.create_doc_table(doc_table)?;
|
||||
|
||||
Ok(doc)
|
||||
}
|
||||
|
||||
pub(crate) async fn update_doc(&self, params: UpdateDocParams) -> Result<(), EditorError> {
|
||||
let changeset = DocTableChangeset::new(params);
|
||||
let _ = self.sql.update_doc_table(changeset)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn read_doc(&self, doc_id: &str) -> Result<DocDescription, EditorError> {
|
||||
let doc_table = self.sql.read_doc_table(doc_id)?;
|
||||
let doc_desc: DocDescription = doc_table.into();
|
||||
Ok(doc_desc)
|
||||
}
|
||||
}
|
@ -6,10 +6,16 @@ use std::{
|
||||
io::{Read, Write},
|
||||
path::{Path, PathBuf},
|
||||
str,
|
||||
sync::atomic::{AtomicUsize, Ordering},
|
||||
time::SystemTime,
|
||||
};
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct FileId(pub(crate) usize);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct FileId(pub(crate) String);
|
||||
|
||||
impl std::convert::From<String> for FileId {
|
||||
fn from(s: String) -> Self { FileId(s) }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum CharacterEncoding {
|
||||
@ -28,15 +34,17 @@ impl CharacterEncoding {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum FileError {
|
||||
Io(io::Error, PathBuf),
|
||||
UnknownEncoding(PathBuf),
|
||||
HasChanged(PathBuf),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct FileInfo {
|
||||
pub path: PathBuf,
|
||||
pub modify_time: Option<SystemTime>,
|
||||
pub modified_time: Option<SystemTime>,
|
||||
pub has_changed: bool,
|
||||
pub encoding: CharacterEncoding,
|
||||
}
|
||||
@ -56,20 +64,13 @@ where
|
||||
let info = FileInfo {
|
||||
encoding,
|
||||
path: path.as_ref().to_owned(),
|
||||
modify_time: get_mod_time(&path),
|
||||
modified_time: get_modified_time(&path),
|
||||
has_changed: false,
|
||||
};
|
||||
Ok((s, info))
|
||||
}
|
||||
|
||||
fn get_mod_time<P: AsRef<Path>>(path: P) -> Option<SystemTime> {
|
||||
File::open(path)
|
||||
.and_then(|f| f.metadata())
|
||||
.and_then(|meta| meta.modified())
|
||||
.ok()
|
||||
}
|
||||
|
||||
fn try_save(
|
||||
pub(crate) fn try_save(
|
||||
path: &Path,
|
||||
text: &str,
|
||||
encoding: CharacterEncoding,
|
||||
@ -97,7 +98,7 @@ fn try_save(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn try_decode(
|
||||
pub(crate) fn try_decode(
|
||||
bytes: Vec<u8>,
|
||||
encoding: CharacterEncoding,
|
||||
path: &Path,
|
||||
@ -115,3 +116,15 @@ fn try_decode(
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn create_dir_if_not_exist(dir: &str) -> Result<(), io::Error> {
|
||||
let _ = fs::create_dir_all(dir)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn get_modified_time<P: AsRef<Path>>(path: P) -> Option<SystemTime> {
|
||||
File::open(path)
|
||||
.and_then(|f| f.metadata())
|
||||
.and_then(|meta| meta.modified())
|
||||
.ok()
|
||||
}
|
||||
|
@ -1,39 +1,123 @@
|
||||
use crate::services::file_manager::*;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
io,
|
||||
path::{Path, PathBuf},
|
||||
sync::{PoisonError, RwLock, RwLockReadGuard},
|
||||
};
|
||||
|
||||
pub(crate) struct FileManagerConfig {
|
||||
doc_dir: String,
|
||||
}
|
||||
|
||||
impl FileManagerConfig {
|
||||
pub fn new(root: &str) -> Self {
|
||||
let doc_dir = format!("{}/doc", root);
|
||||
Self { doc_dir }
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FileManager {
|
||||
config: FileManagerConfig,
|
||||
open_files: HashMap<PathBuf, FileId>,
|
||||
file_info: HashMap<FileId, FileInfo>,
|
||||
}
|
||||
|
||||
impl FileManager {
|
||||
pub fn new() -> Self {
|
||||
pub(crate) fn new(config: FileManagerConfig) -> Self {
|
||||
// let _ = create_dir_if_not_exist(&config.doc_dir)?;
|
||||
Self {
|
||||
config,
|
||||
open_files: HashMap::new(),
|
||||
file_info: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_info(&self, id: FileId) -> Option<&FileInfo> { self.file_info.get(&id) }
|
||||
|
||||
pub fn get_editor(&self, path: &Path) -> Option<FileId> { self.open_files.get(path).cloned() }
|
||||
|
||||
pub fn open(&mut self, path: &Path, id: FileId) -> Result<String, FileError> {
|
||||
pub(crate) fn open<T>(&mut self, path: &Path, id: T) -> Result<String, FileError>
|
||||
where
|
||||
T: Into<FileId>,
|
||||
{
|
||||
if !path.exists() {
|
||||
return Ok("".to_string());
|
||||
}
|
||||
|
||||
let file_id = id.into();
|
||||
let (s, info) = try_load_file(path)?;
|
||||
self.open_files.insert(path.to_owned(), id);
|
||||
self.open_files.insert(path.to_owned(), file_id.clone());
|
||||
self.file_info.insert(file_id, info);
|
||||
|
||||
Ok(s)
|
||||
}
|
||||
|
||||
pub fn close(&mut self, id: FileId) {
|
||||
if let Some(info) = self.file_info.remove(&id) {
|
||||
self.open_files.remove(&info.path);
|
||||
pub(crate) fn save<T>(&mut self, path: &Path, text: &String, id: T) -> Result<(), FileError>
|
||||
where
|
||||
T: Into<FileId>,
|
||||
{
|
||||
let file_id = id.into();
|
||||
let is_existing = self.file_info.contains_key(&file_id);
|
||||
if is_existing {
|
||||
self.save_existing(path, text, &file_id)
|
||||
} else {
|
||||
self.save_new(path, text, &file_id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn close<T>(&mut self, id: T)
|
||||
where
|
||||
T: Into<FileId>,
|
||||
{
|
||||
if let Some(file_info) = self.file_info.remove(&id.into()) {
|
||||
self.open_files.remove(&file_info.path);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn make_file_path(&self, id: &str) -> PathBuf {
|
||||
PathBuf::from(format!("{}/{}", self.config.doc_dir, id))
|
||||
}
|
||||
|
||||
pub(crate) fn get_info(&self, id: &FileId) -> Option<&FileInfo> { self.file_info.get(id) }
|
||||
|
||||
pub(crate) fn get_file_id(&self, path: &Path) -> Option<FileId> {
|
||||
self.open_files.get(path).cloned()
|
||||
}
|
||||
|
||||
pub fn check_file(&mut self, path: &Path, id: &FileId) -> bool {
|
||||
if let Some(info) = self.file_info.get_mut(&id) {
|
||||
let modified_time = get_modified_time(path);
|
||||
if modified_time != info.modified_time {
|
||||
info.has_changed = true
|
||||
}
|
||||
return info.has_changed;
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn save_new(&mut self, path: &Path, text: &String, id: &FileId) -> Result<(), FileError> {
|
||||
try_save(path, text, CharacterEncoding::Utf8, self.get_info(id))
|
||||
.map_err(|e| FileError::Io(e, path.to_owned()))?;
|
||||
let info = FileInfo {
|
||||
encoding: CharacterEncoding::Utf8,
|
||||
path: path.to_owned(),
|
||||
modified_time: get_modified_time(path),
|
||||
has_changed: false,
|
||||
};
|
||||
self.open_files.insert(path.to_owned(), id.clone());
|
||||
self.file_info.insert(id.clone(), info);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn save_existing(&mut self, path: &Path, text: &String, id: &FileId) -> Result<(), FileError> {
|
||||
let prev_path = self.file_info[id].path.clone();
|
||||
if prev_path != path {
|
||||
self.save_new(path, text, id)?;
|
||||
self.open_files.remove(&prev_path);
|
||||
} else if self.file_info[&id].has_changed {
|
||||
return Err(FileError::HasChanged(path.to_owned()));
|
||||
} else {
|
||||
let encoding = self.file_info[&id].encoding;
|
||||
try_save(path, text, encoding, self.get_info(id))
|
||||
.map_err(|e| FileError::Io(e, path.to_owned()))?;
|
||||
self.file_info.get_mut(&id).unwrap().modified_time = get_modified_time(path);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -1 +1,2 @@
|
||||
pub mod doc_controller;
|
||||
pub mod file_manager;
|
||||
|
@ -14,7 +14,7 @@ pub struct DocTableSql {
|
||||
}
|
||||
|
||||
impl DocTableSql {
|
||||
pub(crate) fn write_doc_table(&self, doc_table: DocTable) -> Result<(), EditorError> {
|
||||
pub(crate) fn create_doc_table(&self, doc_table: DocTable) -> Result<(), EditorError> {
|
||||
let conn = self.database.db_connection()?;
|
||||
let _ = diesel::insert_into(doc_table::table)
|
||||
.values(doc_table)
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::entities::doc::{CreateDocParams, Doc, UpdateDocParams};
|
||||
use crate::entities::doc::{CreateDocParams, DocDescription, UpdateDocParams};
|
||||
use flowy_database::schema::doc_table;
|
||||
use flowy_infra::{timestamp, uuid};
|
||||
use std::convert::TryInto;
|
||||
@ -16,13 +16,13 @@ pub(crate) struct DocTable {
|
||||
}
|
||||
|
||||
impl DocTable {
|
||||
pub fn new(params: CreateDocParams) -> Self {
|
||||
pub fn new(params: CreateDocParams, path: &str) -> Self {
|
||||
let time = timestamp();
|
||||
Self {
|
||||
id: params.id,
|
||||
name: params.name,
|
||||
desc: params.desc,
|
||||
path: "".to_owned(),
|
||||
path: path.to_owned(),
|
||||
modified_time: time,
|
||||
create_time: time,
|
||||
version: 0,
|
||||
@ -48,14 +48,13 @@ impl DocTableChangeset {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::Into<Doc> for DocTable {
|
||||
fn into(self) -> Doc {
|
||||
Doc {
|
||||
impl std::convert::Into<DocDescription> for DocTable {
|
||||
fn into(self) -> DocDescription {
|
||||
DocDescription {
|
||||
id: self.id,
|
||||
name: self.name,
|
||||
desc: self.desc,
|
||||
path: self.path,
|
||||
content: "".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
use crate::helper::*;
|
||||
|
||||
#[test]
|
||||
fn file_create_test() {
|
||||
let doc_desc = create_doc("hello world", "flutter ❤️ rust");
|
||||
dbg!(&doc_desc);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_save_test() {
|
||||
let content = "😁😁😁😁😁😁😁😁😁😁".to_owned();
|
||||
let doc_desc = create_doc("hello world", "flutter ❤️ rust");
|
||||
dbg!(&doc_desc);
|
||||
save_doc(&doc_desc, &content);
|
||||
|
||||
let doc = read_doc(&doc_desc.id);
|
||||
assert_eq!(doc.content, content);
|
||||
}
|
48
rust-lib/flowy-editor/tests/editor/helper.rs
Normal file
48
rust-lib/flowy-editor/tests/editor/helper.rs
Normal file
@ -0,0 +1,48 @@
|
||||
use flowy_test::builder::SingleUserTestBuilder;
|
||||
|
||||
use flowy_editor::{entities::doc::*, event::EditorEvent::*};
|
||||
use flowy_infra::uuid;
|
||||
|
||||
pub fn create_doc(name: &str, desc: &str) -> DocDescription {
|
||||
let request = CreateDocRequest {
|
||||
id: uuid(),
|
||||
name: name.to_owned(),
|
||||
desc: desc.to_owned(),
|
||||
};
|
||||
|
||||
let doc_desc = SingleUserTestBuilder::new()
|
||||
.event(CreateDoc)
|
||||
.request(request)
|
||||
.sync_send()
|
||||
.parse::<DocDescription>();
|
||||
|
||||
doc_desc
|
||||
}
|
||||
|
||||
pub fn save_doc(desc: &DocDescription, content: &str) {
|
||||
let request = UpdateDocRequest {
|
||||
id: desc.id.clone(),
|
||||
name: Some(desc.name.clone()),
|
||||
desc: Some(desc.desc.clone()),
|
||||
content: Some(content.to_owned()),
|
||||
};
|
||||
|
||||
let _ = SingleUserTestBuilder::new()
|
||||
.event(UpdateDoc)
|
||||
.request(request)
|
||||
.sync_send();
|
||||
}
|
||||
|
||||
pub fn read_doc(doc_id: &str) -> Doc {
|
||||
let request = QueryDocRequest {
|
||||
doc_id: doc_id.to_string(),
|
||||
};
|
||||
|
||||
let doc = SingleUserTestBuilder::new()
|
||||
.event(ReadDoc)
|
||||
.request(request)
|
||||
.sync_send()
|
||||
.parse::<Doc>();
|
||||
|
||||
doc
|
||||
}
|
@ -1 +1,2 @@
|
||||
mod doc_test;
|
||||
mod helper;
|
||||
|
@ -8,7 +8,7 @@ use std::{path::Path, sync::RwLock};
|
||||
|
||||
const DB_NAME: &str = "kv.db";
|
||||
lazy_static! {
|
||||
pub static ref KV_HOLDER: RwLock<KVStore> = RwLock::new(KVStore::new());
|
||||
static ref KV_HOLDER: RwLock<KVStore> = RwLock::new(KVStore::new());
|
||||
}
|
||||
|
||||
pub struct KVStore {
|
||||
|
21
rust-lib/flowy-sdk/src/deps_resolve/editor_deps_impl.rs
Normal file
21
rust-lib/flowy-sdk/src/deps_resolve/editor_deps_impl.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use flowy_database::DBConnection;
|
||||
use flowy_editor::{
|
||||
errors::{EditorError, EditorErrorCode, ErrorBuilder},
|
||||
module::EditorDatabase,
|
||||
};
|
||||
use flowy_user::prelude::UserSession;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct EditorDatabaseImpl {
|
||||
pub(crate) user_session: Arc<UserSession>,
|
||||
}
|
||||
|
||||
impl EditorDatabase for EditorDatabaseImpl {
|
||||
fn db_connection(&self) -> Result<DBConnection, EditorError> {
|
||||
self.user_session.get_db_connection().map_err(|e| {
|
||||
ErrorBuilder::new(EditorErrorCode::EditorDBConnFailed)
|
||||
.error(e)
|
||||
.build()
|
||||
})
|
||||
}
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
mod workspace_user_impl;
|
||||
mod editor_deps_impl;
|
||||
mod workspace_deps_impl;
|
||||
|
||||
pub use workspace_user_impl::*;
|
||||
pub use editor_deps_impl::*;
|
||||
pub use workspace_deps_impl::*;
|
||||
|
@ -3,7 +3,7 @@ use flowy_dispatch::prelude::Module;
|
||||
use flowy_editor::prelude::*;
|
||||
use flowy_user::prelude::*;
|
||||
|
||||
use crate::deps_resolve::{WorkspaceDatabaseImpl, WorkspaceUserImpl};
|
||||
use crate::deps_resolve::{EditorDatabaseImpl, WorkspaceDatabaseImpl, WorkspaceUserImpl};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct ModuleConfig {
|
||||
@ -21,13 +21,18 @@ pub fn build_modules(config: ModuleConfig, _server: ArcFlowyServer) -> Vec<Modul
|
||||
user_session: user_session.clone(),
|
||||
});
|
||||
|
||||
let workspace_data_impl = Arc::new(WorkspaceDatabaseImpl {
|
||||
let workspace_db = Arc::new(WorkspaceDatabaseImpl {
|
||||
user_session: user_session.clone(),
|
||||
});
|
||||
|
||||
let editor_db = Arc::new(EditorDatabaseImpl {
|
||||
user_session: user_session.clone(),
|
||||
});
|
||||
let editor_config = EditorConfig::new(&config.root);
|
||||
|
||||
vec![
|
||||
flowy_user::module::create(user_session),
|
||||
flowy_workspace::module::create(workspace_user_impl, workspace_data_impl),
|
||||
flowy_editor::module::create(),
|
||||
flowy_workspace::module::create(workspace_user_impl, workspace_db),
|
||||
flowy_editor::module::create(editor_db, editor_config),
|
||||
]
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ use flowy_workspace::errors::WorkspaceError;
|
||||
use std::{marker::PhantomData, sync::Once};
|
||||
static INIT: Once = Once::new();
|
||||
|
||||
pub type WorkspaceTestBuilder = TestBuilder<FixedUserTester<WorkspaceError>>;
|
||||
impl WorkspaceTestBuilder {
|
||||
pub type SingleUserTestBuilder = TestBuilder<FixedUserTester<WorkspaceError>>;
|
||||
impl SingleUserTestBuilder {
|
||||
pub fn new() -> Self {
|
||||
let mut builder = Self {
|
||||
tester: Box::new(FixedUserTester::<WorkspaceError>::new()),
|
||||
|
@ -15,7 +15,7 @@ pub async fn create_app(
|
||||
controller: ModuleData<Arc<AppController>>,
|
||||
) -> ResponseResult<App, WorkspaceError> {
|
||||
let params: CreateAppParams = data.into_inner().try_into()?;
|
||||
let detail = controller.save_app(params)?;
|
||||
let detail = controller.create_app(params)?;
|
||||
response_ok(detail)
|
||||
}
|
||||
|
||||
@ -25,9 +25,9 @@ pub async fn get_app(
|
||||
controller: ModuleData<Arc<AppController>>,
|
||||
) -> ResponseResult<App, WorkspaceError> {
|
||||
let params: QueryAppParams = data.into_inner().try_into()?;
|
||||
let mut app = controller.get_app(¶ms.app_id).await?;
|
||||
let mut app = controller.read_app(¶ms.app_id).await?;
|
||||
if params.read_views {
|
||||
let views = controller.get_views(¶ms.app_id).await?;
|
||||
let views = controller.read_views(¶ms.app_id).await?;
|
||||
app.views = RepeatedView { items: views };
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,6 @@ pub async fn create_view(
|
||||
controller: ModuleData<Arc<ViewController>>,
|
||||
) -> ResponseResult<View, WorkspaceError> {
|
||||
let params: CreateViewParams = data.into_inner().try_into()?;
|
||||
let view = controller.save_view(params).await?;
|
||||
let view = controller.create_view(params).await?;
|
||||
response_ok(view)
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ pub async fn create_workspace(
|
||||
) -> ResponseResult<Workspace, WorkspaceError> {
|
||||
let controller = controller.get_ref().clone();
|
||||
let params: CreateWorkspaceParams = data.into_inner().try_into()?;
|
||||
let detail = controller.save_workspace(params).await?;
|
||||
let detail = controller.create_workspace(params).await?;
|
||||
response_ok(detail)
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ pub async fn create_workspace(
|
||||
pub async fn get_cur_workspace(
|
||||
controller: ModuleData<Arc<WorkspaceController>>,
|
||||
) -> ResponseResult<Workspace, WorkspaceError> {
|
||||
let workspace = controller.get_cur_workspace().await?;
|
||||
let workspace = controller.read_cur_workspace().await?;
|
||||
response_ok(workspace)
|
||||
}
|
||||
|
||||
@ -31,10 +31,10 @@ pub async fn get_workspace(
|
||||
controller: ModuleData<Arc<WorkspaceController>>,
|
||||
) -> ResponseResult<Workspace, WorkspaceError> {
|
||||
let params: QueryWorkspaceParams = data.into_inner().try_into()?;
|
||||
let mut workspace = controller.get_workspace(¶ms.workspace_id).await?;
|
||||
let mut workspace = controller.read_workspace(¶ms.workspace_id).await?;
|
||||
|
||||
if params.read_apps {
|
||||
let apps = controller.get_apps(¶ms.workspace_id).await?;
|
||||
let apps = controller.read_apps(¶ms.workspace_id).await?;
|
||||
workspace.apps = RepeatedApp { items: apps };
|
||||
}
|
||||
|
||||
|
@ -32,28 +32,28 @@ impl AppController {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn save_app(&self, params: CreateAppParams) -> Result<App, WorkspaceError> {
|
||||
pub fn create_app(&self, params: CreateAppParams) -> Result<App, WorkspaceError> {
|
||||
let app_table = AppTable::new(params);
|
||||
let app: App = app_table.clone().into();
|
||||
let _ = self.sql.write_app_table(app_table)?;
|
||||
let _ = self.sql.create_app(app_table)?;
|
||||
send_observable(&app.workspace_id, WorkspaceObservable::WorkspaceAddApp);
|
||||
Ok(app)
|
||||
}
|
||||
|
||||
pub async fn get_app(&self, app_id: &str) -> Result<App, WorkspaceError> {
|
||||
let app_table = self.get_app_table(app_id).await?;
|
||||
pub async fn read_app(&self, app_id: &str) -> Result<App, WorkspaceError> {
|
||||
let app_table = self.async_read_app(&app_id).await?;
|
||||
Ok(app_table.into())
|
||||
}
|
||||
|
||||
pub fn update_app(&self, params: UpdateAppParams) -> Result<(), WorkspaceError> {
|
||||
let changeset = AppTableChangeset::new(params);
|
||||
let app_id = changeset.id.clone();
|
||||
let _ = self.sql.update_app_table(changeset)?;
|
||||
let _ = self.sql.update_app(changeset)?;
|
||||
send_observable(&app_id, WorkspaceObservable::AppUpdateDesc);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn get_views(&self, app_id: &str) -> Result<Vec<View>, WorkspaceError> {
|
||||
pub async fn read_views(&self, app_id: &str) -> Result<Vec<View>, WorkspaceError> {
|
||||
let views = self
|
||||
.sql
|
||||
.read_views_belong_to_app(app_id)?
|
||||
@ -64,12 +64,12 @@ impl AppController {
|
||||
Ok(views)
|
||||
}
|
||||
|
||||
fn get_app_table(&self, app_id: &str) -> DispatchFuture<Result<AppTable, WorkspaceError>> {
|
||||
fn async_read_app(&self, app_id: &str) -> DispatchFuture<Result<AppTable, WorkspaceError>> {
|
||||
let sql = self.sql.clone();
|
||||
let app_id = app_id.to_owned();
|
||||
DispatchFuture {
|
||||
fut: Box::pin(async move {
|
||||
let app_table = sql.read_app_table(&app_id)?;
|
||||
let app_table = sql.read_app(&app_id)?;
|
||||
// TODO: fetch app from remote server
|
||||
Ok(app_table)
|
||||
}),
|
||||
|
@ -17,10 +17,10 @@ impl ViewController {
|
||||
Self { sql }
|
||||
}
|
||||
|
||||
pub async fn save_view(&self, params: CreateViewParams) -> Result<View, WorkspaceError> {
|
||||
pub async fn create_view(&self, params: CreateViewParams) -> Result<View, WorkspaceError> {
|
||||
let view_table = ViewTable::new(params);
|
||||
let view: View = view_table.clone().into();
|
||||
let _ = self.sql.write_view_table(view_table)?;
|
||||
let _ = self.sql.create_view(view_table)?;
|
||||
|
||||
send_observable(&view.id, WorkspaceObservable::AppAddView);
|
||||
Ok(view)
|
||||
|
@ -29,13 +29,13 @@ impl WorkspaceController {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn save_workspace(
|
||||
pub async fn create_workspace(
|
||||
&self,
|
||||
params: CreateWorkspaceParams,
|
||||
) -> Result<Workspace, WorkspaceError> {
|
||||
let workspace_table = WorkspaceTable::new(params);
|
||||
let detail: Workspace = workspace_table.clone().into();
|
||||
let _ = self.sql.write_workspace_table(workspace_table)?;
|
||||
let _ = self.sql.create_workspace(workspace_table)?;
|
||||
let _ = self.user.set_cur_workspace_id(&detail.id).await?;
|
||||
|
||||
Ok(detail)
|
||||
@ -54,24 +54,24 @@ impl WorkspaceController {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub async fn get_cur_workspace(&self) -> Result<Workspace, WorkspaceError> {
|
||||
pub async fn read_cur_workspace(&self) -> Result<Workspace, WorkspaceError> {
|
||||
let user_workspace = self.user.get_cur_workspace().await?;
|
||||
let workspace = self.get_workspace(&user_workspace.workspace_id).await?;
|
||||
let workspace = self.read_workspace(&user_workspace.workspace_id).await?;
|
||||
Ok(workspace)
|
||||
}
|
||||
|
||||
pub async fn get_cur_apps(&self) -> Result<Vec<App>, WorkspaceError> {
|
||||
pub async fn read_cur_apps(&self) -> Result<Vec<App>, WorkspaceError> {
|
||||
let user_workspace = self.user.get_cur_workspace().await?;
|
||||
let apps = self.get_apps(&user_workspace.workspace_id).await?;
|
||||
let apps = self.read_apps(&user_workspace.workspace_id).await?;
|
||||
Ok(apps)
|
||||
}
|
||||
|
||||
pub async fn get_workspace(&self, workspace_id: &str) -> Result<Workspace, WorkspaceError> {
|
||||
let workspace_table = self.get_workspace_table(workspace_id).await?;
|
||||
pub async fn read_workspace(&self, workspace_id: &str) -> Result<Workspace, WorkspaceError> {
|
||||
let workspace_table = self.read_workspace_table(workspace_id).await?;
|
||||
Ok(workspace_table.into())
|
||||
}
|
||||
|
||||
pub async fn get_apps(&self, workspace_id: &str) -> Result<Vec<App>, WorkspaceError> {
|
||||
pub async fn read_apps(&self, workspace_id: &str) -> Result<Vec<App>, WorkspaceError> {
|
||||
let apps = self
|
||||
.sql
|
||||
.read_apps_belong_to_workspace(workspace_id)?
|
||||
@ -82,7 +82,7 @@ impl WorkspaceController {
|
||||
Ok(apps)
|
||||
}
|
||||
|
||||
fn get_workspace_table(
|
||||
fn read_workspace_table(
|
||||
&self,
|
||||
workspace_id: &str,
|
||||
) -> DispatchFuture<Result<WorkspaceTable, WorkspaceError>> {
|
||||
|
@ -18,7 +18,7 @@ pub struct AppTableSql {
|
||||
}
|
||||
|
||||
impl AppTableSql {
|
||||
pub(crate) fn write_app_table(&self, app_table: AppTable) -> Result<(), WorkspaceError> {
|
||||
pub(crate) fn create_app(&self, app_table: AppTable) -> Result<(), WorkspaceError> {
|
||||
let conn = self.database.db_connection()?;
|
||||
let _ = diesel::insert_into(app_table::table)
|
||||
.values(app_table)
|
||||
@ -26,16 +26,13 @@ impl AppTableSql {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn update_app_table(
|
||||
&self,
|
||||
changeset: AppTableChangeset,
|
||||
) -> Result<(), WorkspaceError> {
|
||||
pub(crate) fn update_app(&self, changeset: AppTableChangeset) -> Result<(), WorkspaceError> {
|
||||
let conn = self.database.db_connection()?;
|
||||
diesel_update_table!(app_table, changeset, conn);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn read_app_table(&self, app_id: &str) -> Result<AppTable, WorkspaceError> {
|
||||
pub(crate) fn read_app(&self, app_id: &str) -> Result<AppTable, WorkspaceError> {
|
||||
let app_table = dsl::app_table
|
||||
.filter(app_table::id.eq(app_id))
|
||||
.first::<AppTable>(&*(self.database.db_connection()?))?;
|
||||
|
@ -11,7 +11,7 @@ pub struct ViewTableSql {
|
||||
}
|
||||
|
||||
impl ViewTableSql {
|
||||
pub(crate) fn write_view_table(&self, view_table: ViewTable) -> Result<(), WorkspaceError> {
|
||||
pub(crate) fn create_view(&self, view_table: ViewTable) -> Result<(), WorkspaceError> {
|
||||
let conn = self.database.db_connection()?;
|
||||
let _ = diesel::insert_into(view_table::table)
|
||||
.values(view_table)
|
||||
|
@ -17,10 +17,7 @@ pub struct WorkspaceSql {
|
||||
}
|
||||
|
||||
impl WorkspaceSql {
|
||||
pub fn write_workspace_table(
|
||||
&self,
|
||||
workspace_table: WorkspaceTable,
|
||||
) -> Result<(), WorkspaceError> {
|
||||
pub fn create_workspace(&self, workspace_table: WorkspaceTable) -> Result<(), WorkspaceError> {
|
||||
let _ = diesel::insert_into(workspace_table::table)
|
||||
.values(workspace_table)
|
||||
.execute(&*(self.database.db_connection()?))?;
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::helper::*;
|
||||
use flowy_test::builder::WorkspaceTestBuilder;
|
||||
use flowy_test::builder::SingleUserTestBuilder;
|
||||
use flowy_workspace::{
|
||||
entities::{
|
||||
app::{App, CreateAppRequest, QueryAppRequest},
|
||||
|
@ -1,4 +1,4 @@
|
||||
pub use flowy_test::builder::WorkspaceTestBuilder;
|
||||
pub use flowy_test::builder::SingleUserTestBuilder;
|
||||
use flowy_workspace::{
|
||||
entities::{app::*, view::*, workspace::*},
|
||||
event::WorkspaceEvent::*,
|
||||
@ -17,7 +17,7 @@ pub fn create_workspace(name: &str, desc: &str) -> Workspace {
|
||||
desc: desc.to_owned(),
|
||||
};
|
||||
|
||||
let workspace = WorkspaceTestBuilder::new()
|
||||
let workspace = SingleUserTestBuilder::new()
|
||||
.event(CreateWorkspace)
|
||||
.request(request)
|
||||
.sync_send()
|
||||
@ -34,7 +34,7 @@ pub fn create_app(name: &str, desc: &str, workspace_id: &str) -> App {
|
||||
color_style: Default::default(),
|
||||
};
|
||||
|
||||
let app = WorkspaceTestBuilder::new()
|
||||
let app = SingleUserTestBuilder::new()
|
||||
.event(CreateApp)
|
||||
.request(create_app_request)
|
||||
.sync_send()
|
||||
@ -43,7 +43,7 @@ pub fn create_app(name: &str, desc: &str, workspace_id: &str) -> App {
|
||||
}
|
||||
|
||||
pub fn get_workspace(request: QueryWorkspaceRequest) -> Workspace {
|
||||
let workspace = WorkspaceTestBuilder::new()
|
||||
let workspace = SingleUserTestBuilder::new()
|
||||
.event(GetWorkspace)
|
||||
.request(request)
|
||||
.sync_send()
|
||||
@ -53,7 +53,7 @@ pub fn get_workspace(request: QueryWorkspaceRequest) -> Workspace {
|
||||
}
|
||||
|
||||
pub fn get_app(request: QueryAppRequest) -> App {
|
||||
let app = WorkspaceTestBuilder::new()
|
||||
let app = SingleUserTestBuilder::new()
|
||||
.event(GetApp)
|
||||
.request(request)
|
||||
.sync_send()
|
||||
@ -63,7 +63,7 @@ pub fn get_app(request: QueryAppRequest) -> App {
|
||||
}
|
||||
|
||||
pub fn create_view(request: CreateViewRequest) -> View {
|
||||
let view = WorkspaceTestBuilder::new()
|
||||
let view = SingleUserTestBuilder::new()
|
||||
.event(CreateView)
|
||||
.request(request)
|
||||
.sync_send()
|
||||
|
@ -14,7 +14,7 @@ fn workspace_create_success() { let _ = create_workspace("First workspace", "");
|
||||
|
||||
#[test]
|
||||
fn workspace_get_success() {
|
||||
let workspace = WorkspaceTestBuilder::new()
|
||||
let workspace = SingleUserTestBuilder::new()
|
||||
.event(GetCurWorkspace)
|
||||
.sync_send()
|
||||
.parse::<Workspace>();
|
||||
@ -60,7 +60,7 @@ fn workspace_create_with_invalid_name_test() {
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
WorkspaceTestBuilder::new()
|
||||
SingleUserTestBuilder::new()
|
||||
.event(CreateWorkspace)
|
||||
.request(request)
|
||||
.sync_send()
|
||||
@ -80,7 +80,7 @@ fn workspace_update_with_invalid_name_test() {
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
WorkspaceTestBuilder::new()
|
||||
SingleUserTestBuilder::new()
|
||||
.event(CreateWorkspace)
|
||||
.request(request)
|
||||
.sync_send()
|
||||
|
Loading…
Reference in New Issue
Block a user