You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: unit_ops.go
    path of file: ./repos/juju/state
    
    the code of the file until where you have to start completion: // Copyright 2020 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package state

import (
	"github.com/juju/errors"
	"github.com/juju/mgo/v3"
	"github.com/juju/mgo/v3/bson"
	"github.com/juju/mgo/v3/txn"
	jujutxn "github.com/juju/txn/v3"

	"github.com/juju/juju/core/quota"
	mgoutils "github.com/juju/juju/mongo/utils"
)

type unitSetStateOperation struct {
	u        *Unit
	newState *UnitState

	// Quota limits for updating the charm and uniter state data.
	limits UnitStateSizeLimits
}

// Build implements ModelOperation.
func (op *unitSetStateOperation) Build(attempt int) ([]txn.Op, error) {
	if op.newState == nil || !op.newState.Modified() {
		return nil, jujutxn.ErrNoOperations
	}
	return op.buildTxn(attempt)
}

func (op *unitSetStateOperation) buildTxn(att
    
func (op *unitSetStateOperation) newUnitStateDoc(unitGlobalKey string) (unitStateDoc, error) {
	newStDoc := unitStateDoc{
		DocID: unitGlobalKey,
	}
	if chState, found := op.newState.CharmState(); found {
		escapedCharmState := make(map[string]string, len(chState))
		for k, v := range chState {
			escapedCharmState[mgoutils.EscapeKey(k)] = v
		}
		newStDoc.CharmState = escapedCharmState

		quotaChecker := op.getCharmStateQuotaChecker()
		quotaChecker.Check(newStDoc.CharmState)
		if err := quotaChecker.Outcome(); err != nil {
			return unitStateDoc{}, errors.Annotatef(err, "persisting charm state")
		}
	}

	quotaChecker := op.getUniterStateQuotaChecker()
	if rState, found := op.newState.relationStateBSONFriendly(); found {
		newStDoc.RelationState = rState
		quotaChecker.Check(rState)
	}
	if uniterState, found := op.newState.UniterState(); found {
		newStDoc.UniterState = uniterState
		quotaChecker.Check(uniterState)
	}
	if storState, found := op.newState.StorageState(); found {
		newStDoc.StorageState = storState
		quotaChecker.Check(storState)
	}
	if secretState, found := op.newState.SecretState(); found {
		newStDoc.SecretState = secretState
		quotaChecker.Check(secretState)
	}
	if meterStatusState, found := op.newState.MeterStatusState(); found {
		newStDoc.MeterStatusState = meterStatusState
		quotaChecker.Check(meterStatusState)
	}
	if err := quotaChecker.Outcome(); err != nil {
		return unitStateDoc{}, errors.Annotatef(err, "persisting uniter state")
	}
	return newStDoc, nil
}