Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
*/
package io.vertx.grpc.common;

import com.google.protobuf.Descriptors;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Message;
import com.google.protobuf.MessageOrBuilder;
import com.google.protobuf.Parser;
import com.google.protobuf.util.JsonFormat;
import io.vertx.codegen.annotations.Unstable;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.DecodeException;
import io.vertx.core.json.Json;
Expand Down Expand Up @@ -60,6 +62,10 @@ public T decode(GrpcMessage msg) throws CodecException {
public boolean accepts(WireFormat format) {
return true;
}
@Override
public Descriptors.Descriptor messageDescriptor() {
return dit.getDescriptorForType();
}
};
}

Expand Down Expand Up @@ -165,8 +171,31 @@ public boolean accepts(WireFormat format) {
}
};

/**
* Decodes a given gRPC message into an object of type {@code T}.
*
* @param msg the gRPC message to decode
* @return the decoded message of type {@code T}
* @throws CodecException if the decoding process fails
*/
T decode(GrpcMessage msg) throws CodecException;

/**
* Determines whether the given {@link WireFormat} is supported by this decoder.
*
* @param format the wire format to check
* @return true if the given wire format is accepted, false otherwise
*/
boolean accepts(WireFormat format);

/**
* Returns the protobuf message descriptor if this decoder was created from a protobuf message type, {@code null} otherwise.
*
* @return the protobuf descriptor or {@code null}
*/
@Unstable
default Descriptors.Descriptor messageDescriptor() {
return null;
}

}
Loading
Loading