Package io.flutter.plugin.common
Interface MethodCodec
-
- All Known Implementing Classes:
JSONMethodCodec,StandardMethodCodec
public interface MethodCodecA codec for method calls and enveloped results.Method calls are encoded as binary messages with enough structure that the codec can extract a method name String and an arguments Object. These data items are used to populate a
MethodCall.All operations throw
IllegalArgumentException, if conversion fails.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ObjectdecodeEnvelope(ByteBuffer envelope)Decodes a result envelope from binary.MethodCalldecodeMethodCall(ByteBuffer methodCall)Decodes a message call from binary.ByteBufferencodeErrorEnvelope(String errorCode, String errorMessage, Object errorDetails)Encodes an error result into a binary envelope message.ByteBufferencodeErrorEnvelopeWithStacktrace(String errorCode, String errorMessage, Object errorDetails, String errorStacktrace)Encodes an error result into a binary envelope message with the native stacktrace.ByteBufferencodeMethodCall(MethodCall methodCall)Encodes a message call into binary.ByteBufferencodeSuccessEnvelope(Object result)Encodes a successful result into a binary envelope message.
-
-
-
Method Detail
-
encodeMethodCall
@NonNull ByteBuffer encodeMethodCall(@NonNull MethodCall methodCall)
Encodes a message call into binary.- Parameters:
methodCall- aMethodCall.- Returns:
- a
ByteBuffercontaining the encoding between position 0 and the current position.
-
decodeMethodCall
@NonNull MethodCall decodeMethodCall(@NonNull ByteBuffer methodCall)
Decodes a message call from binary.- Parameters:
methodCall- the binary encoding of the method call as aByteBuffer.- Returns:
- a
MethodCallrepresentation of the bytes between the given buffer's current position and its limit.
-
encodeSuccessEnvelope
@NonNull ByteBuffer encodeSuccessEnvelope(@Nullable Object result)
Encodes a successful result into a binary envelope message.- Parameters:
result- The result value, possibly null.- Returns:
- a
ByteBuffercontaining the encoding between position 0 and the current position.
-
encodeErrorEnvelope
@NonNull ByteBuffer encodeErrorEnvelope(@NonNull String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails)
Encodes an error result into a binary envelope message.- Parameters:
errorCode- An error code String.errorMessage- An error message String, possibly null.errorDetails- Error details, possibly null. Consider supportingThrowablein your codec. This is the most common value passed to this field.- Returns:
- a
ByteBuffercontaining the encoding between position 0 and the current position.
-
encodeErrorEnvelopeWithStacktrace
@NonNull ByteBuffer encodeErrorEnvelopeWithStacktrace(@NonNull String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails, @Nullable String errorStacktrace)
Encodes an error result into a binary envelope message with the native stacktrace.- Parameters:
errorCode- An error code String.errorMessage- An error message String, possibly null.errorDetails- Error details, possibly null. Consider supportingThrowablein your codec. This is the most common value passed to this field.errorStacktrace- Platform stacktrace for the error. possibly null.- Returns:
- a
ByteBuffercontaining the encoding between position 0 and the current position.
-
decodeEnvelope
@NonNull Object decodeEnvelope(@NonNull ByteBuffer envelope)
Decodes a result envelope from binary.- Parameters:
envelope- the binary encoding of a result envelope as aByteBuffer.- Returns:
- the enveloped result Object.
- Throws:
FlutterException- if the envelope was an error envelope.
-
-