code: func (v VirtualMachine) WaitForPowerState(ctx context.Context, state types.VirtualMachinePowerState) error {
  	p := property.DefaultCollector(v.c)
  	err := property.Wait(ctx, p, v.Reference(), []string{PropRuntimePowerState}, func(pc []types.PropertyChange) bool {
  		for _, c := range pc {
  			if c.Name != PropRuntimePowerState {
  				continue
  			}
  			if c.Val == nil {
  				continue
  			}
  
  			ps := c.Val.(types.VirtualMachinePowerState)
  			if ps == state {
  				return true
  			}
  		}
  		return false
  	})
  
  	return err
  }
docs: // Wait for the VirtualMachine to change to the desired power state.