private static int InvokeInit(IntPtr managed_handle, IntPtr status)
        {
            return(SenderAdapter.InvokeAndUnwrapExceptions(
                       (ApiStatus apiStatus) =>
            {
                SenderAdapter adapter = GetAdapterOrThrow(managed_handle);

                adapter.senderImplementation.Init(apiStatus);
                return apiStatus.ErrorCode;
            },
                       status
                       ));
        }
        private static int InvokeSend(IntPtr managed_handle, IntPtr buffer, IntPtr status)
        {
            return(SenderAdapter.InvokeAndUnwrapExceptions(
                       (ApiStatus apiStatus) =>
            {
                SenderAdapter adapter = GetAdapterOrThrow(managed_handle);
                SharedBuffer sharedBuffer = new SharedBuffer(buffer);

                // Buffer must live at least as long as the underlying call.
                unsafe {
                    adapter.senderImplementation.Send(sharedBuffer, apiStatus);
                }

                return apiStatus.ErrorCode;
            },
                       status
                       ));
        }