mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Added an additional constructor that takes only the InputFile, and then generates an id automatically.
PiperOrigin-RevId: 405712536
This commit is contained in:
committed by
Copybara-Service
parent
4b5be77ed6
commit
ef57b09fc3
+8
-3
@@ -33,6 +33,11 @@ Payload::Payload(ByteArray&& bytes) : content_(std::move(bytes)) {}
|
||||
|
||||
Payload::Payload(const ByteArray& bytes) : content_(bytes) {}
|
||||
|
||||
Payload::Payload(InputFile file)
|
||||
: content_(std::move(file)),
|
||||
id_(std::hash<std::string>()(file.GetFilePath())) {}
|
||||
|
||||
// TODO(jfcarroll): Convert std::function to function pointer
|
||||
Payload::Payload(std::function<InputStream&()> stream)
|
||||
: content_(std::move(stream)) {}
|
||||
|
||||
@@ -42,12 +47,12 @@ Payload::Payload(Id id, ByteArray&& bytes)
|
||||
|
||||
Payload::Payload(Id id, const ByteArray& bytes) : content_(bytes), id_(id) {}
|
||||
|
||||
Payload::Payload(Id id, InputFile file) : content_(std::move(file)), id_(id) {}
|
||||
|
||||
// TODO(jfcarroll): Convert std::function to function pointer
|
||||
Payload::Payload(Id id, std::function<InputStream&()> stream)
|
||||
: content_(std::move(stream)), id_(id) {}
|
||||
|
||||
// Constructor for incoming and outgoing file payloads.
|
||||
Payload::Payload(Id id, InputFile file) : content_(std::move(file)), id_(id) {}
|
||||
|
||||
// Returns ByteArray payload, if it has been defined, or empty ByteArray.
|
||||
const ByteArray& Payload::AsBytes() const& {
|
||||
static const ByteArray empty; // NOLINT: function-level static is OK.
|
||||
|
||||
+2
-2
@@ -56,15 +56,15 @@ class DLL_API Payload {
|
||||
explicit Payload(ByteArray&& bytes);
|
||||
|
||||
explicit Payload(const ByteArray& bytes);
|
||||
explicit Payload(InputFile file);
|
||||
explicit Payload(std::function<InputStream&()> stream);
|
||||
|
||||
// Constructors for incoming payloads.
|
||||
Payload(Id id, ByteArray&& bytes);
|
||||
Payload(Id id, const ByteArray& bytes);
|
||||
Payload(Id id, InputFile file);
|
||||
Payload(Id id, std::function<InputStream&()> stream);
|
||||
|
||||
// Constructor for incoming and outgoing file payloads.
|
||||
Payload(Id id, InputFile file);
|
||||
|
||||
// Returns ByteArray payload, if it has been defined, or empty ByteArray.
|
||||
const ByteArray& AsBytes() const&;
|
||||
|
||||
Reference in New Issue
Block a user