Skip to content

Commit

Permalink
generated.dart -> protobuf.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Lesches committed Dec 6, 2024
1 parent 7ec8005 commit 07cbb7b
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 63 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.3.0

- Deprecate `generated.dart` in favor of `protobuf.dart`

## SKIP A FEW

## 1.0.0

- Initial version.
2 changes: 1 addition & 1 deletion lib/burt_network.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export "src/utils.dart";
export "service.dart";

export "generated.dart";
export "protobuf.dart";
export "logging.dart";
export "udp.dart";
export "serial.dart";
58 changes: 2 additions & 56 deletions lib/generated.dart
Original file line number Diff line number Diff line change
@@ -1,58 +1,4 @@
/// This library exports the generated Protobuf classes.
///
/// Nothing in this library is hand-written. See our [Protobuf repository](https://github.com/BinghamtonRover/Protobuf) for more details.
@Deprecated("Use package:burt_network/protobuf instead")
library;

export "src/generated/arm.pb.dart";
export "src/generated/base_station.pb.dart";
export "src/generated/autonomy.pb.dart";
export "src/generated/core.pb.dart";
export "src/generated/drive.pb.dart";
export "src/generated/gps.pb.dart";
export "src/generated/logs.pb.dart";
export "src/generated/motor.pb.dart";
export "src/generated/status.pb.dart";
export "src/generated/science.pb.dart";
export "src/generated/utils.pb.dart";
export "src/generated/version.pb.dart";
export "src/generated/video.pb.dart";
export "src/generated/wrapper.pb.dart";

export "src/generated/google/protobuf/timestamp.pb.dart";

import "package:protobuf/protobuf.dart" as proto;

import "src/generated/wrapper.pb.dart";
import "src/generated/google/protobuf/timestamp.pb.dart";

/// A cleaner name for any message generated by Protobuf.
typedef Message = proto.GeneratedMessage;

/// Defines a friendlier method for getting the name of a message.
extension MessageUtils on Message {
/// The name of the message as declared in the .proto file.
String get messageName => info_.messageName;

/// Returns a [WrappedMessage] representing this message with a timestamp
WrappedMessage wrap([DateTime? timestamp]) => WrappedMessage(
data: writeToBuffer(),
name: messageName,
timestamp: Timestamp.fromDateTime(timestamp ?? DateTime.now()),
);
}

/// Helpful methods on lists of Protobuf enums.
extension EnumUtils<T extends proto.ProtobufEnum> on List<T> {
/// Filters out the `UNDEFINED` value.
List<T> get filtered => [
for (final value in this)
if (value.value != 0)
value,
];

/// A list of all the enum value names.
List<String> get names => [
for (final value in filtered)
value.name,
];
}
export "protobuf.dart";
60 changes: 60 additions & 0 deletions lib/protobuf.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/// This library exports the generated Protobuf classes.
///
/// Nothing in this library is hand-written. See our [Protobuf repository](https://github.com/BinghamtonRover/Protobuf) for more details.
library;

export "src/generated/arm.pb.dart";
export "src/generated/base_station.pb.dart";
export "src/generated/autonomy.pb.dart";
export "src/generated/core.pb.dart";
export "src/generated/drive.pb.dart";
export "src/generated/gps.pb.dart";
export "src/generated/logs.pb.dart";
export "src/generated/motor.pb.dart";
export "src/generated/status.pb.dart";
export "src/generated/science.pb.dart";
export "src/generated/utils.pb.dart";
export "src/generated/version.pb.dart";
export "src/generated/video.pb.dart";
export "src/generated/wrapper.pb.dart";

export "src/utils.dart";

export "src/generated/google/protobuf/timestamp.pb.dart";

import "package:protobuf/protobuf.dart" as proto;

import "src/generated/wrapper.pb.dart";
import "src/generated/google/protobuf/timestamp.pb.dart";

/// A cleaner name for any message generated by Protobuf.
typedef Message = proto.GeneratedMessage;

/// Defines a friendlier method for getting the name of a message.
extension MessageUtils on Message {
/// The name of the message as declared in the .proto file.
String get messageName => info_.messageName;

/// Returns a [WrappedMessage] representing this message with a timestamp
WrappedMessage wrap([DateTime? timestamp]) => WrappedMessage(
data: writeToBuffer(),
name: messageName,
timestamp: Timestamp.fromDateTime(timestamp ?? DateTime.now()),
);
}

/// Helpful methods on lists of Protobuf enums.
extension EnumUtils<T extends proto.ProtobufEnum> on List<T> {
/// Filters out the `UNDEFINED` value.
List<T> get filtered => [
for (final value in this)
if (value.value != 0)
value,
];

/// A list of all the enum value names.
List<String> get names => [
for (final value in filtered)
value.name,
];
}
2 changes: 1 addition & 1 deletion lib/src/udp/rover_heartbeats.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import "package:burt_network/generated.dart";
import "package:burt_network/protobuf.dart";

import "burt_socket.dart";
import "socket_info.dart";
Expand Down
2 changes: 1 addition & 1 deletion lib/src/udp/rover_logger.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "package:burt_network/generated.dart";
import "package:burt_network/protobuf.dart";

import "burt_socket.dart";
import "socket_info.dart";
Expand Down
4 changes: 2 additions & 2 deletions lib/src/udp/rover_settings.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import "dart:io";

import "package:burt_network/generated.dart";
import "package:burt_network/protobuf.dart";

import "burt_socket.dart";

/// A mixin that handles [UpdateSetting] commands.
mixin RoverSettings on BurtSocket {
/// Whether this code is being run in a test environment.
/// Whether this code is being run in a test environment.
static bool isTest = false;

/// Handles an [UpdateSetting] command and updates the appropriate setting.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/utils.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "dart:async";
import "dart:math";

import "package:burt_network/generated.dart";
import "package:burt_network/protobuf.dart";

/// JSON data as a map.
typedef Json = Map<String, dynamic>;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: burt_network
description: A starting point for Dart libraries or applications.
version: 2.2.0
version: 2.3.0
publish_to: none
repository: https://github.com/BinghamtonRover/Networking

Expand Down

0 comments on commit 07cbb7b

Please sign in to comment.