43 lines
1.2 KiB
C#
Raw Normal View History

2020-01-11 17:56:12 +01:00
namespace Capnp.Rpc
2019-06-12 21:56:55 +02:00
{
/// <summary>
/// Helper struct to support tail calls
/// </summary>
public struct AnswerOrCounterquestion
{
readonly object _obj;
AnswerOrCounterquestion(object obj)
{
_obj = obj;
}
/// <summary>
/// Wraps a SerializerState
/// </summary>
/// <param name="answer">object to wrap</param>
2019-06-12 21:56:55 +02:00
public static implicit operator AnswerOrCounterquestion (SerializerState answer)
{
return new AnswerOrCounterquestion(answer);
}
/// <summary>
/// Wraps a PendingQuestion
/// </summary>
/// <param name="counterquestion">object to wrap</param>
2019-06-12 21:56:55 +02:00
public static implicit operator AnswerOrCounterquestion (PendingQuestion counterquestion)
{
return new AnswerOrCounterquestion(counterquestion);
}
/// <summary>
/// SerializerState, if applicable
/// </summary>
2020-01-11 17:21:31 +01:00
public SerializerState? Answer => _obj as SerializerState;
/// <summary>
/// PendingQuestion, if applicable
/// </summary>
2020-01-11 17:21:31 +01:00
public PendingQuestion? Counterquestion => _obj as PendingQuestion;
2019-06-12 21:56:55 +02:00
}
2020-01-11 17:56:12 +01:00
}