Unifying theory of quantum state estimation using past and future information