def from_state(cls, state): state["headers"] = Headers.from_state(state["headers"]) if state["trailers"] is not None: state["trailers"] = Headers.from_state(state["trailers"]) return cls(**state)
def set_state(self, state): for k, v in state.items(): if k in ("headers", "trailers") and v is not None: v = Headers.from_state(v) setattr(self, k, v)