create flutter protobuf model automatically

This commit is contained in:
appflowy 2021-07-06 09:08:24 +08:00
parent 8f615fd115
commit 751d1dd3d3
36 changed files with 976 additions and 437 deletions

View File

@ -0,0 +1,20 @@
export 'protobuf/sign_in.pbjson.pb.dart';
export 'protobuf/sign_in.pb.pb.dart';
export 'protobuf/ffi_response.pbjson.pb.dart';
export 'protobuf/ffi_request.pbserver.pb.dart';
export 'protobuf/ffi_response.pb.pb.dart';
export 'protobuf/user.pbenum.pb.dart';
export 'protobuf/user.pbserver.pb.dart';
export 'protobuf/ffi_request.pbjson.pb.dart';
export 'protobuf/sign_up.pbjson.pb.dart';
export 'protobuf/ffi_request.pbenum.pb.dart';
export 'protobuf/sign_up.pbenum.pb.dart';
export 'protobuf/sign_up.pbserver.pb.dart';
export 'protobuf/user.pbjson.pb.dart';
export 'protobuf/ffi_response.pbserver.pb.dart';
export 'protobuf/ffi_response.pbenum.pb.dart';
export 'protobuf/sign_in.pbserver.pb.dart';
export 'protobuf/sign_up.pb.pb.dart';
export 'protobuf/user.pb.pb.dart';
export 'protobuf/sign_in.pbenum.pb.dart';
export 'protobuf/ffi_request.pb.pb.dart';

View File

@ -0,0 +1,72 @@
///
// Generated code. Do not modify.
// source: ffi_request.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class FFIRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'FFIRequest', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'event')
..a<$core.List<$core.int>>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'payload', $pb.PbFieldType.OY)
..hasRequiredFields = false
;
FFIRequest._() : super();
factory FFIRequest({
$core.String? event,
$core.List<$core.int>? payload,
}) {
final _result = create();
if (event != null) {
_result.event = event;
}
if (payload != null) {
_result.payload = payload;
}
return _result;
}
factory FFIRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory FFIRequest.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')
FFIRequest clone() => FFIRequest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
FFIRequest copyWith(void Function(FFIRequest) updates) => super.copyWith((message) => updates(message as FFIRequest)) as FFIRequest; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static FFIRequest create() => FFIRequest._();
FFIRequest createEmptyInstance() => create();
static $pb.PbList<FFIRequest> createRepeated() => $pb.PbList<FFIRequest>();
@$core.pragma('dart2js:noInline')
static FFIRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<FFIRequest>(create);
static FFIRequest? _defaultInstance;
@$pb.TagNumber(1)
$core.String get event => $_getSZ(0);
@$pb.TagNumber(1)
set event($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasEvent() => $_has(0);
@$pb.TagNumber(1)
void clearEvent() => clearField(1);
@$pb.TagNumber(2)
$core.List<$core.int> get payload => $_getN(1);
@$pb.TagNumber(2)
set payload($core.List<$core.int> v) { $_setBytes(1, v); }
@$pb.TagNumber(2)
$core.bool hasPayload() => $_has(1);
@$pb.TagNumber(2)
void clearPayload() => clearField(2);
}

View File

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

View File

@ -0,0 +1,16 @@
///
// Generated code. Do not modify.
// source: ffi_request.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;
const FFIRequest$json = const {
'1': 'FFIRequest',
'2': const [
const {'1': 'event', '3': 1, '4': 1, '5': 9, '10': 'event'},
const {'1': 'payload', '3': 2, '4': 1, '5': 12, '10': 'payload'},
],
};

View File

@ -0,0 +1,9 @@
///
// Generated code. Do not modify.
// source: ffi_request.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
export 'ffi_request.pb.dart';

View File

@ -0,0 +1,86 @@
///
// Generated code. Do not modify.
// source: ffi_response.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class FFIResponse extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'FFIResponse', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'event')
..a<$core.List<$core.int>>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'payload', $pb.PbFieldType.OY)
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'error')
..hasRequiredFields = false
;
FFIResponse._() : super();
factory FFIResponse({
$core.String? event,
$core.List<$core.int>? payload,
$core.String? error,
}) {
final _result = create();
if (event != null) {
_result.event = event;
}
if (payload != null) {
_result.payload = payload;
}
if (error != null) {
_result.error = error;
}
return _result;
}
factory FFIResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory FFIResponse.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')
FFIResponse clone() => FFIResponse()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
FFIResponse copyWith(void Function(FFIResponse) updates) => super.copyWith((message) => updates(message as FFIResponse)) as FFIResponse; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static FFIResponse create() => FFIResponse._();
FFIResponse createEmptyInstance() => create();
static $pb.PbList<FFIResponse> createRepeated() => $pb.PbList<FFIResponse>();
@$core.pragma('dart2js:noInline')
static FFIResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<FFIResponse>(create);
static FFIResponse? _defaultInstance;
@$pb.TagNumber(1)
$core.String get event => $_getSZ(0);
@$pb.TagNumber(1)
set event($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasEvent() => $_has(0);
@$pb.TagNumber(1)
void clearEvent() => clearField(1);
@$pb.TagNumber(2)
$core.List<$core.int> get payload => $_getN(1);
@$pb.TagNumber(2)
set payload($core.List<$core.int> v) { $_setBytes(1, v); }
@$pb.TagNumber(2)
$core.bool hasPayload() => $_has(1);
@$pb.TagNumber(2)
void clearPayload() => clearField(2);
@$pb.TagNumber(3)
$core.String get error => $_getSZ(2);
@$pb.TagNumber(3)
set error($core.String v) { $_setString(2, v); }
@$pb.TagNumber(3)
$core.bool hasError() => $_has(2);
@$pb.TagNumber(3)
void clearError() => clearField(3);
}

View File

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

View File

@ -0,0 +1,17 @@
///
// Generated code. Do not modify.
// source: ffi_response.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;
const FFIResponse$json = const {
'1': 'FFIResponse',
'2': const [
const {'1': 'event', '3': 1, '4': 1, '5': 9, '10': 'event'},
const {'1': 'payload', '3': 2, '4': 1, '5': 12, '10': 'payload'},
const {'1': 'error', '3': 3, '4': 1, '5': 9, '10': 'error'},
],
};

View File

@ -0,0 +1,9 @@
///
// Generated code. Do not modify.
// source: ffi_response.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
export 'ffi_response.pb.dart';

View File

@ -0,0 +1,180 @@
///
// Generated code. Do not modify.
// source: sign_in.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class UserSignInParams extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserSignInParams', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'email')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'password')
..hasRequiredFields = false
;
UserSignInParams._() : super();
factory UserSignInParams({
$core.String? email,
$core.String? password,
}) {
final _result = create();
if (email != null) {
_result.email = email;
}
if (password != null) {
_result.password = password;
}
return _result;
}
factory UserSignInParams.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory UserSignInParams.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')
UserSignInParams clone() => UserSignInParams()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
UserSignInParams copyWith(void Function(UserSignInParams) updates) => super.copyWith((message) => updates(message as UserSignInParams)) as UserSignInParams; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static UserSignInParams create() => UserSignInParams._();
UserSignInParams createEmptyInstance() => create();
static $pb.PbList<UserSignInParams> createRepeated() => $pb.PbList<UserSignInParams>();
@$core.pragma('dart2js:noInline')
static UserSignInParams getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserSignInParams>(create);
static UserSignInParams? _defaultInstance;
@$pb.TagNumber(1)
$core.String get email => $_getSZ(0);
@$pb.TagNumber(1)
set email($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasEmail() => $_has(0);
@$pb.TagNumber(1)
void clearEmail() => clearField(1);
@$pb.TagNumber(2)
$core.String get password => $_getSZ(1);
@$pb.TagNumber(2)
set password($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasPassword() => $_has(1);
@$pb.TagNumber(2)
void clearPassword() => clearField(2);
}
class UserSignInRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserSignInRequest', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'email')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'password')
..hasRequiredFields = false
;
UserSignInRequest._() : super();
factory UserSignInRequest({
$core.String? email,
$core.String? password,
}) {
final _result = create();
if (email != null) {
_result.email = email;
}
if (password != null) {
_result.password = password;
}
return _result;
}
factory UserSignInRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory UserSignInRequest.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')
UserSignInRequest clone() => UserSignInRequest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
UserSignInRequest copyWith(void Function(UserSignInRequest) updates) => super.copyWith((message) => updates(message as UserSignInRequest)) as UserSignInRequest; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static UserSignInRequest create() => UserSignInRequest._();
UserSignInRequest createEmptyInstance() => create();
static $pb.PbList<UserSignInRequest> createRepeated() => $pb.PbList<UserSignInRequest>();
@$core.pragma('dart2js:noInline')
static UserSignInRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserSignInRequest>(create);
static UserSignInRequest? _defaultInstance;
@$pb.TagNumber(1)
$core.String get email => $_getSZ(0);
@$pb.TagNumber(1)
set email($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasEmail() => $_has(0);
@$pb.TagNumber(1)
void clearEmail() => clearField(1);
@$pb.TagNumber(2)
$core.String get password => $_getSZ(1);
@$pb.TagNumber(2)
set password($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasPassword() => $_has(1);
@$pb.TagNumber(2)
void clearPassword() => clearField(2);
}
class UserSignInResult extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserSignInResult', createEmptyInstance: create)
..aOB(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isSuccess')
..hasRequiredFields = false
;
UserSignInResult._() : super();
factory UserSignInResult({
$core.bool? isSuccess,
}) {
final _result = create();
if (isSuccess != null) {
_result.isSuccess = isSuccess;
}
return _result;
}
factory UserSignInResult.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory UserSignInResult.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')
UserSignInResult clone() => UserSignInResult()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
UserSignInResult copyWith(void Function(UserSignInResult) updates) => super.copyWith((message) => updates(message as UserSignInResult)) as UserSignInResult; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static UserSignInResult create() => UserSignInResult._();
UserSignInResult createEmptyInstance() => create();
static $pb.PbList<UserSignInResult> createRepeated() => $pb.PbList<UserSignInResult>();
@$core.pragma('dart2js:noInline')
static UserSignInResult getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserSignInResult>(create);
static UserSignInResult? _defaultInstance;
@$pb.TagNumber(1)
$core.bool get isSuccess => $_getBF(0);
@$pb.TagNumber(1)
set isSuccess($core.bool v) { $_setBool(0, v); }
@$pb.TagNumber(1)
$core.bool hasIsSuccess() => $_has(0);
@$pb.TagNumber(1)
void clearIsSuccess() => clearField(1);
}

View File

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

View File

@ -0,0 +1,31 @@
///
// Generated code. Do not modify.
// source: sign_in.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;
const UserSignInParams$json = const {
'1': 'UserSignInParams',
'2': const [
const {'1': 'email', '3': 1, '4': 1, '5': 9, '10': 'email'},
const {'1': 'password', '3': 2, '4': 1, '5': 9, '10': 'password'},
],
};
const UserSignInRequest$json = const {
'1': 'UserSignInRequest',
'2': const [
const {'1': 'email', '3': 1, '4': 1, '5': 9, '10': 'email'},
const {'1': 'password', '3': 2, '4': 1, '5': 9, '10': 'password'},
],
};
const UserSignInResult$json = const {
'1': 'UserSignInResult',
'2': const [
const {'1': 'is_success', '3': 1, '4': 1, '5': 8, '10': 'isSuccess'},
],
};

View File

@ -0,0 +1,9 @@
///
// Generated code. Do not modify.
// source: sign_in.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
export 'sign_in.pb.dart';

View File

@ -0,0 +1,208 @@
///
// Generated code. Do not modify.
// source: sign_up.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class UserSignUpParams extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserSignUpParams', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'email')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'password')
..hasRequiredFields = false
;
UserSignUpParams._() : super();
factory UserSignUpParams({
$core.String? email,
$core.String? name,
$core.String? password,
}) {
final _result = create();
if (email != null) {
_result.email = email;
}
if (name != null) {
_result.name = name;
}
if (password != null) {
_result.password = password;
}
return _result;
}
factory UserSignUpParams.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory UserSignUpParams.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')
UserSignUpParams clone() => UserSignUpParams()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
UserSignUpParams copyWith(void Function(UserSignUpParams) updates) => super.copyWith((message) => updates(message as UserSignUpParams)) as UserSignUpParams; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static UserSignUpParams create() => UserSignUpParams._();
UserSignUpParams createEmptyInstance() => create();
static $pb.PbList<UserSignUpParams> createRepeated() => $pb.PbList<UserSignUpParams>();
@$core.pragma('dart2js:noInline')
static UserSignUpParams getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserSignUpParams>(create);
static UserSignUpParams? _defaultInstance;
@$pb.TagNumber(1)
$core.String get email => $_getSZ(0);
@$pb.TagNumber(1)
set email($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasEmail() => $_has(0);
@$pb.TagNumber(1)
void clearEmail() => 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 password => $_getSZ(2);
@$pb.TagNumber(3)
set password($core.String v) { $_setString(2, v); }
@$pb.TagNumber(3)
$core.bool hasPassword() => $_has(2);
@$pb.TagNumber(3)
void clearPassword() => clearField(3);
}
class UserSignUpRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserSignUpRequest', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'email')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'password')
..hasRequiredFields = false
;
UserSignUpRequest._() : super();
factory UserSignUpRequest({
$core.String? email,
$core.String? name,
$core.String? password,
}) {
final _result = create();
if (email != null) {
_result.email = email;
}
if (name != null) {
_result.name = name;
}
if (password != null) {
_result.password = password;
}
return _result;
}
factory UserSignUpRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory UserSignUpRequest.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')
UserSignUpRequest clone() => UserSignUpRequest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
UserSignUpRequest copyWith(void Function(UserSignUpRequest) updates) => super.copyWith((message) => updates(message as UserSignUpRequest)) as UserSignUpRequest; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static UserSignUpRequest create() => UserSignUpRequest._();
UserSignUpRequest createEmptyInstance() => create();
static $pb.PbList<UserSignUpRequest> createRepeated() => $pb.PbList<UserSignUpRequest>();
@$core.pragma('dart2js:noInline')
static UserSignUpRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserSignUpRequest>(create);
static UserSignUpRequest? _defaultInstance;
@$pb.TagNumber(1)
$core.String get email => $_getSZ(0);
@$pb.TagNumber(1)
set email($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasEmail() => $_has(0);
@$pb.TagNumber(1)
void clearEmail() => 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 password => $_getSZ(2);
@$pb.TagNumber(3)
set password($core.String v) { $_setString(2, v); }
@$pb.TagNumber(3)
$core.bool hasPassword() => $_has(2);
@$pb.TagNumber(3)
void clearPassword() => clearField(3);
}
class UserSignUpResult extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserSignUpResult', createEmptyInstance: create)
..aOB(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isSuccess')
..hasRequiredFields = false
;
UserSignUpResult._() : super();
factory UserSignUpResult({
$core.bool? isSuccess,
}) {
final _result = create();
if (isSuccess != null) {
_result.isSuccess = isSuccess;
}
return _result;
}
factory UserSignUpResult.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory UserSignUpResult.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')
UserSignUpResult clone() => UserSignUpResult()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
UserSignUpResult copyWith(void Function(UserSignUpResult) updates) => super.copyWith((message) => updates(message as UserSignUpResult)) as UserSignUpResult; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static UserSignUpResult create() => UserSignUpResult._();
UserSignUpResult createEmptyInstance() => create();
static $pb.PbList<UserSignUpResult> createRepeated() => $pb.PbList<UserSignUpResult>();
@$core.pragma('dart2js:noInline')
static UserSignUpResult getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserSignUpResult>(create);
static UserSignUpResult? _defaultInstance;
@$pb.TagNumber(1)
$core.bool get isSuccess => $_getBF(0);
@$pb.TagNumber(1)
set isSuccess($core.bool v) { $_setBool(0, v); }
@$pb.TagNumber(1)
$core.bool hasIsSuccess() => $_has(0);
@$pb.TagNumber(1)
void clearIsSuccess() => clearField(1);
}

View File

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

View File

@ -0,0 +1,33 @@
///
// Generated code. Do not modify.
// source: sign_up.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;
const UserSignUpParams$json = const {
'1': 'UserSignUpParams',
'2': const [
const {'1': 'email', '3': 1, '4': 1, '5': 9, '10': 'email'},
const {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
const {'1': 'password', '3': 3, '4': 1, '5': 9, '10': 'password'},
],
};
const UserSignUpRequest$json = const {
'1': 'UserSignUpRequest',
'2': const [
const {'1': 'email', '3': 1, '4': 1, '5': 9, '10': 'email'},
const {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
const {'1': 'password', '3': 3, '4': 1, '5': 9, '10': 'password'},
],
};
const UserSignUpResult$json = const {
'1': 'UserSignUpResult',
'2': const [
const {'1': 'is_success', '3': 1, '4': 1, '5': 8, '10': 'isSuccess'},
],
};

View File

@ -0,0 +1,9 @@
///
// Generated code. Do not modify.
// source: sign_up.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
export 'sign_up.pb.dart';

View File

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

View File

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

View File

@ -0,0 +1,17 @@
///
// Generated code. Do not modify.
// source: user.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;
const User$json = const {
'1': 'User',
'2': const [
const {'1': 'name', '3': 1, '4': 1, '5': 9, '10': 'name'},
const {'1': 'email', '3': 2, '4': 1, '5': 9, '10': 'email'},
const {'1': 'password', '3': 3, '4': 1, '5': 9, '10': 'password'},
],
};

View File

@ -0,0 +1,9 @@
///
// Generated code. Do not modify.
// source: user.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
export 'user.pb.dart';

View File

@ -7,7 +7,6 @@ members = [
"flowy-user",
"flowy-ast",
"flowy-derive",
"flowy-protobuf",
]
[profile.dev]

View File

@ -270,16 +270,16 @@ static file_descriptor_proto_data: &'static [u8] = b"\
\n\x12ffi_response.proto\"S\n\x0bFFIResponse\x12\x14\n\x05event\x18\x01\
\x20\x01(\tR\x05event\x12\x18\n\x07payload\x18\x02\x20\x01(\x0cR\x07payl\
oad\x12\x14\n\x05error\x18\x03\x20\x01(\tR\x05errorJ\xcf\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\
\x01\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\x01\x08\x13\n\x0b\n\x04\x04\0\
\x02\0\x12\x03\x02\x04\x15\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x02\x04\n\
\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x02\x0b\x10\n\x0c\n\x05\x04\0\x02\0\
\x03\x12\x03\x02\x13\x14\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x03\x04\x16\n\
\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x03\x04\t\n\x0c\n\x05\x04\0\x02\x01\
\x01\x12\x03\x03\n\x11\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x03\x14\x15\
\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x04\x04\x15\n\x0c\n\x05\x04\0\x02\x02\
\x05\x12\x03\x04\x04\n\n\x0c\n\x05\x04\0\x02\x02\x01\x12\x03\x04\x0b\x10\
\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x04\x13\x14b\x06proto3\
\x04\0\0\x06\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\x13\n\x0b\n\x04\x04\0\
\x02\0\x12\x03\x03\x04\x15\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\x10\n\x0c\n\x05\x04\0\x02\0\
\x03\x12\x03\x03\x13\x14\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x04\x16\n\
\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\x04\t\n\x0c\n\x05\x04\0\x02\x01\
\x01\x12\x03\x04\n\x11\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04\x14\x15\
\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x05\x04\x15\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\x10\
\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x05\x13\x14b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -1,4 +1,5 @@
syntax = "proto3";
message FFIResponse {
string event = 1;
bytes payload = 2;

View File

@ -1,9 +0,0 @@
[package]
name = "flowy-protobuf"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
protobuf = {version = "2.20.0"}

View File

@ -1,7 +0,0 @@
syntax = "proto3";
message App {
string id = 1;
string workspace_id = 2;
string name = 3;
}

View File

@ -1,4 +0,0 @@
max_width = 80
ignore = [
"**/define/*.proto",
]

View File

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

View File

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

View File

@ -1,295 +0,0 @@
// 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 `user.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 App {
// message fields
pub id: ::std::string::String,
pub workspace_id: ::std::string::String,
pub name: ::std::string::String,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a App {
fn default() -> &'a App {
<App as ::protobuf::Message>::default_instance()
}
}
impl App {
pub fn new() -> App {
::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 workspace_id = 2;
pub fn get_workspace_id(&self) -> &str {
&self.workspace_id
}
pub fn clear_workspace_id(&mut self) {
self.workspace_id.clear();
}
// Param is passed by value, moved
pub fn set_workspace_id(&mut self, v: ::std::string::String) {
self.workspace_id = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_workspace_id(&mut self) -> &mut ::std::string::String {
&mut self.workspace_id
}
// Take field
pub fn take_workspace_id(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.workspace_id, ::std::string::String::new())
}
// string name = 3;
pub fn get_name(&self) -> &str {
&self.name
}
pub fn clear_name(&mut self) {
self.name.clear();
}
// Param is passed by value, moved
pub fn set_name(&mut self, v: ::std::string::String) {
self.name = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_name(&mut self) -> &mut ::std::string::String {
&mut self.name
}
// Take field
pub fn take_name(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.name, ::std::string::String::new())
}
}
impl ::protobuf::Message for App {
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.workspace_id)?;
},
3 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.name)?;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if !self.id.is_empty() {
my_size += ::protobuf::rt::string_size(1, &self.id);
}
if !self.workspace_id.is_empty() {
my_size += ::protobuf::rt::string_size(2, &self.workspace_id);
}
if !self.name.is_empty() {
my_size += ::protobuf::rt::string_size(3, &self.name);
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if !self.id.is_empty() {
os.write_string(1, &self.id)?;
}
if !self.workspace_id.is_empty() {
os.write_string(2, &self.workspace_id)?;
}
if !self.name.is_empty() {
os.write_string(3, &self.name)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> App {
App::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: &App| { &m.id },
|m: &mut App| { &mut m.id },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"workspace_id",
|m: &App| { &m.workspace_id },
|m: &mut App| { &mut m.workspace_id },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"name",
|m: &App| { &m.name },
|m: &mut App| { &mut m.name },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<App>(
"App",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static App {
static instance: ::protobuf::rt::LazyV2<App> = ::protobuf::rt::LazyV2::INIT;
instance.get(App::new)
}
}
impl ::protobuf::Clear for App {
fn clear(&mut self) {
self.id.clear();
self.workspace_id.clear();
self.name.clear();
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for App {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for App {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\nuser.proto\"L\n\x03App\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\
!\n\x0cworkspace_id\x18\x02\x20\x01(\tR\x0bworkspaceId\x12\x12\n\x04name\
\x18\x03\x20\x01(\tR\x04nameJ\xcf\x01\n\x06\x12\x04\0\0\x06\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\x0b\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\x1c\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\x17\
\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04\x1a\x1b\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\x13b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
}
pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
file_descriptor_proto_lazy.get(|| {
parse_descriptor_proto()
})
}

View File

@ -13,16 +13,12 @@ fn main() {
if let Some(ref matches) = matches.subcommand_matches("pb-gen") {
let rust_source = matches.value_of("rust_source").unwrap();
let derive_meta = matches.value_of("derive_meta").unwrap();
let rust_mod_dir = matches.value_of("rust_mod_dir").unwrap();
let flutter_mod_dir = matches.value_of("flutter_mod_dir").unwrap();
let proto_file_output = matches.value_of("proto_file_output").unwrap();
let flutter_package_lib = matches.value_of("flutter_package_lib").unwrap();
proto::ProtoGenBuilder::new()
.set_rust_source_dir(rust_source)
.set_derive_meta_dir(derive_meta)
.set_rust_mod_dir(rust_mod_dir)
.set_flutter_mod_dir(flutter_mod_dir)
.set_proto_file_output_dir(proto_file_output)
.set_flutter_package_lib(flutter_package_lib)
.build()
.gen();
}
@ -49,20 +45,9 @@ pub fn app<'a, 'b>() -> App<'a, 'b> {
.help("Caching information used by flowy-derive"),
)
.arg(
Arg::with_name("rust_mod_dir")
.long("rust_mod_dir")
Arg::with_name("flutter_package_lib")
.long("flutter_package_lib")
.value_name("DIRECTORY"),
)
.arg(
Arg::with_name("flutter_mod_dir")
.long("flutter_mod_dir")
.value_name("DIRECTORY"),
)
.arg(
Arg::with_name("proto_file_output")
.long("proto_file_output")
.value_name("DIRECTORY")
.help("The path is used to save the generated proto file"),
),
);

View File

@ -3,9 +3,7 @@ use crate::proto::ProtoGen;
#[allow(dead_code)]
pub struct ProtoGenBuilder {
rust_source_dir: Option<String>,
proto_file_output_dir: Option<String>,
rust_mod_dir: Option<String>,
flutter_mod_dir: Option<String>,
flutter_package_lib: Option<String>,
derive_meta_dir: Option<String>,
}
@ -13,9 +11,7 @@ impl ProtoGenBuilder {
pub fn new() -> Self {
ProtoGenBuilder {
rust_source_dir: None,
proto_file_output_dir: None,
rust_mod_dir: None,
flutter_mod_dir: None,
flutter_package_lib: None,
derive_meta_dir: None,
}
}
@ -25,18 +21,8 @@ impl ProtoGenBuilder {
self
}
pub fn set_proto_file_output_dir(mut self, dir: &str) -> Self {
self.proto_file_output_dir = Some(dir.to_string());
self
}
pub fn set_rust_mod_dir(mut self, dir: &str) -> Self {
self.rust_mod_dir = Some(dir.to_string());
self
}
pub fn set_flutter_mod_dir(mut self, dir: &str) -> Self {
self.flutter_mod_dir = Some(dir.to_string());
pub fn set_flutter_package_lib(mut self, dir: &str) -> Self {
self.flutter_package_lib = Some(dir.to_string());
self
}
@ -48,7 +34,7 @@ impl ProtoGenBuilder {
pub fn build(self) -> ProtoGen {
ProtoGen {
rust_source_dir: self.rust_source_dir.unwrap(),
flutter_mod_dir: self.flutter_mod_dir.unwrap(),
flutter_package_lib: self.flutter_package_lib.unwrap(),
derive_meta_dir: self.derive_meta_dir.unwrap(),
}
}

View File

@ -22,25 +22,19 @@ impl CrateInfo {
pub fn proto_file_output_dir(&self) -> String {
let dir = format!("{}/proto", self.protobuf_crate_name());
self.create_file_if_not_exist(dir.as_ref());
create_dir_if_not_exist(dir.as_ref());
dir
}
pub fn proto_struct_output_dir(&self) -> String {
let dir = format!("{}/model", self.protobuf_crate_name());
self.create_file_if_not_exist(dir.as_ref());
create_dir_if_not_exist(dir.as_ref());
dir
}
pub fn proto_model_mod_file(&self) -> String {
format!("{}/mod.rs", self.proto_struct_output_dir())
}
fn create_file_if_not_exist(&self, dir: &str) {
if !std::path::Path::new(&dir).exists() {
std::fs::create_dir_all(&dir).unwrap();
}
}
}
impl CrateProtoInfo {
@ -134,3 +128,9 @@ pub fn is_hidden(entry: &walkdir::DirEntry) -> bool {
.map(|s| s.starts_with("."))
.unwrap_or(false)
}
pub fn create_dir_if_not_exist(dir: &str) {
if !std::path::Path::new(&dir).exists() {
std::fs::create_dir_all(&dir).unwrap();
}
}

View File

@ -4,27 +4,29 @@ use crate::{proto::template::*, util::*};
use std::{fs::OpenOptions, io::Write};
use std::fs::File;
use walkdir::WalkDir;
pub struct ProtoGen {
pub(crate) rust_source_dir: String,
pub(crate) flutter_mod_dir: String,
pub(crate) flutter_package_lib: String,
pub(crate) derive_meta_dir: String,
}
impl ProtoGen {
pub fn gen(&self) {
let crate_proto_infos = parse_crate_protobuf(self.rust_source_dir.as_ref());
write_proto_files(&crate_proto_infos);
run_protoc(&crate_proto_infos);
run_rust_protoc(&crate_proto_infos);
write_rust_crate_mod_file(&crate_proto_infos);
write_protobuf_crate_mod_file(&crate_proto_infos);
let package_root = self.flutter_package_lib.as_ref();
let model_dir = format!("{}/protobuf", package_root);
run_flutter_protoc(&crate_proto_infos, model_dir.as_ref());
write_flutter_crate_mod_file(package_root, model_dir.as_ref());
write_derive_meta(&crate_proto_infos, self.derive_meta_dir.as_ref());
write_rust_crate_protobuf(&crate_proto_infos);
}
}
@ -42,7 +44,7 @@ fn write_proto_files(crate_infos: &Vec<CrateProtoInfo>) {
}
}
fn write_rust_crate_protobuf(crate_infos: &Vec<CrateProtoInfo>) {
fn write_rust_crate_mod_file(crate_infos: &Vec<CrateProtoInfo>) {
for crate_info in crate_infos {
let mod_path = crate_info.inner.proto_model_mod_file();
match OpenOptions::new()
@ -54,20 +56,15 @@ fn write_rust_crate_protobuf(crate_infos: &Vec<CrateProtoInfo>) {
{
Ok(ref mut file) => {
let mut mod_file_content = String::new();
for (_, file_name) in WalkDir::new(crate_info.inner.proto_file_output_dir())
.into_iter()
.filter_map(|e| e.ok())
.filter(|e| e.file_type().is_dir() == false)
.map(|e| {
(
e.path().to_str().unwrap().to_string(),
e.path().file_stem().unwrap().to_str().unwrap().to_string(),
)
})
{
let c = format!("\nmod {}; \npub use {}::*; \n", &file_name, &file_name);
mod_file_content.push_str(c.as_ref());
}
mod_file_content.push_str("// Auto-generated, do not edit \n");
walk_dir(
crate_info.inner.proto_file_output_dir().as_ref(),
|e| e.file_type().is_dir() == false,
|_, name| {
let c = format!("\nmod {}; \npub use {}::*; \n", &name, &name);
mod_file_content.push_str(c.as_ref());
},
);
file.write_all(mod_file_content.as_bytes()).unwrap();
}
Err(err) => {
@ -77,30 +74,93 @@ fn write_rust_crate_protobuf(crate_infos: &Vec<CrateProtoInfo>) {
}
}
fn run_protoc(crate_infos: &Vec<CrateProtoInfo>) {
for crate_info in crate_infos {
let rust_out = crate_info.inner.proto_struct_output_dir();
let proto_path = crate_info.inner.proto_file_output_dir();
for proto_file in WalkDir::new(&proto_path)
.into_iter()
.filter_map(|e| e.ok())
.filter(|e| is_proto_file(e))
.map(|e| e.path().to_str().unwrap().to_string())
{
if cmd_lib::run_cmd! {
protoc --rust_out=${rust_out} --proto_path=${proto_path} ${proto_file}
}
.is_err()
{
panic!("Create protobuf rust struct fail")
};
fn write_flutter_crate_mod_file(package_root: &str, model_dir: &str) {
let mod_path = format!("{}/protobuf.dart", package_root);
match OpenOptions::new()
.create(true)
.write(true)
.append(false)
.truncate(true)
.open(&mod_path)
{
Ok(ref mut file) => {
let mut mod_file_content = String::new();
mod_file_content.push_str("// Auto-generated, do not edit \n");
walk_dir(
model_dir,
|e| e.file_type().is_dir() == false,
|_, name| {
let c = format!("export 'protobuf/{}.pb.dart';\n", &name);
mod_file_content.push_str(c.as_ref());
},
);
file.write_all(mod_file_content.as_bytes()).unwrap();
file.flush().unwrap();
}
Err(err) => {
panic!("Failed to open file: {}", err);
}
}
}
fn write_protobuf_crate_mod_file(crate_infos: &Vec<CrateProtoInfo>) {
fn run_rust_protoc(crate_infos: &Vec<CrateProtoInfo>) {
for crate_info in crate_infos {
let rust_out = crate_info.inner.proto_struct_output_dir();
let proto_path = crate_info.inner.proto_file_output_dir();
walk_dir(
proto_path.as_ref(),
|e| is_proto_file(e),
|proto_file, _| {
if cmd_lib::run_cmd! {
protoc --rust_out=${rust_out} --proto_path=${proto_path} ${proto_file}
}
.is_err()
{
panic!("Run flutter protoc fail")
};
},
);
crate_info.create_crate_mod_file();
}
}
fn run_flutter_protoc(crate_infos: &Vec<CrateProtoInfo>, model_dir: &str) {
create_dir_if_not_exist(model_dir.as_ref());
for crate_info in crate_infos {
let proto_path = crate_info.inner.proto_file_output_dir();
walk_dir(
proto_path.as_ref(),
|e| is_proto_file(e),
|proto_file, _| {
if cmd_lib::run_cmd! {
protoc --dart_out=${model_dir} --proto_path=${proto_path} ${proto_file}
}
.is_err()
{
panic!("Run flutter protoc fail")
};
},
);
}
}
fn walk_dir<F1, F2>(dir: &str, filter: F2, mut path_and_name: F1)
where
F1: FnMut(String, String),
F2: Fn(&walkdir::DirEntry) -> bool,
{
for (path, name) in WalkDir::new(dir)
.into_iter()
.filter_map(|e| e.ok())
.filter(|e| filter(e))
.map(|e| {
(
e.path().to_str().unwrap().to_string(),
e.path().file_stem().unwrap().to_str().unwrap().to_string(),
)
})
{
path_and_name(path, name);
}
}

View File

@ -10,31 +10,14 @@ script = [
rust_lib=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib
flutter_lib=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/packages
rust_flowy_protobuf=${rust_lib}/flowy-protobuf
flutter_flowy_protobuf=${flutter_lib}/flowy_protobuf
derive_meta=${rust_lib}/flowy-derive/src/derive_cache/derive_cache.rs
proto_file_output=${rust_flowy_protobuf}/define
rust_mod_dir=${rust_flowy_protobuf}/src/
flutter_mod_dir=${flutter_flowy_protobuf}/src/
flutter_package_lib=${flutter_lib}/flowy_sdk/lib
cargo run \
--manifest-path ${pb_gen_bin} pb-gen \
--rust_source=${rust_source} \
--derive_meta=${derive_meta} \
--proto_file_output=${proto_file_output} \
--rust_mod_dir=${rust_mod_dir} \
--flutter_mod_dir=${flutter_mod_dir}
--flutter_package_lib=${flutter_package_lib}
""",
]
script_runner = "@shell"
[tasks.gen_rust_pb]
script = [
"""
protoc --rust_out=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/flowy-protobuf/src/model \
--proto_path=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/flowy-protobuf/define \
${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/flowy-protobuf/define/*.proto
""",
]
script_runner = "@shell"