turn writer into a generic store interface with separate encoding functions