Files
engine/shell/platform/android/io/flutter/plugin/common/MessageCodec.java
T
Mikkel Nygaard Ravn 74de13c0bd FlutterXxxChannel concepts added to support Flutter/Android interop (#3446)
New concepts: FlutterMessageChannel (basic message send/receive superseding existing FlutterView methods), FlutterMethodChannel (method invocation and event streams), pluggable codecs for messages and method calls: unencoded binary, string, json, and 'standard' flutter binary encoding.
2017-03-01 13:54:32 +01:00

33 lines
1.0 KiB
Java

// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package io.flutter.plugin.common;
import java.nio.ByteBuffer;
/**
* A message encoding/decoding mechanism.
*
* Both operations throw {@link IllegalArgumentException}, if conversion fails.
*/
public interface MessageCodec<T> {
/**
* Encodes the specified message into binary.
*
* @param message the T message, possibly null.
* @return a ByteBuffer containing the encoding between position 0 and
* the current position, or null, if message is null.
*/
ByteBuffer encodeMessage(T message);
/**
* Decodes the specified message from binary.
*
* @param message the {@link ByteBuffer} message, possibly null.
* @return a T value representation of the bytes between the given buffer's current
* position and its limit, or null, if message is null.
*/
T decodeMessage(ByteBuffer message);
}