// CopyFrom copies data from ctx into this context, including span identity and baggage.
// TODO This is only used by interop.go. Remove once TChannel Go supports OpenTracing.
975936
func (c *SpanContext) CopyFrom(ctx *SpanContext) {
	c.traceID = ctx.traceID
	c.spanID = ctx.spanID
	c.parentID = ctx.parentID
	c.flags = ctx.flags
	if l := len(ctx.baggage); l > 0 {
		c.baggage = make(map[string]string, l)
		for k, v := range ctx.baggage {
			c.baggage[k] = v
		}
	} else {
		c.baggage = nil
	}
}
439024
func (c *Client) CopyFromContainer(opts CopyFromContainerOptions) error {
	if opts.Container == "" {
		return &NoSuchContainer{ID: opts.Container}
	}
	if c.serverAPIVersion == nil {
		c.checkAPIVersion()
	}
	if c.serverAPIVersion != nil && c.serverAPIVersion.GreaterThanOrEqualTo(apiVersion124) {
		return errors.New("go-dockerclient: CopyFromContainer is no longer available in Docker >= 1.12, use DownloadFromContainer instead")
	}
	url := fmt.Sprintf("/containers/%s/copy", opts.Container)
	resp, err := c.do("POST", url, doOptions{
		data:    opts,
		context: opts.Context,
	})
	if err != nil {
		if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
			return &NoSuchContainer{ID: opts.Container}
		}
		return err
	}
	defer resp.Body.Close()
	_, err = io.Copy(opts.OutputStream, resp.Body)
	return err
}
515332
func (f *FlowRemoved) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &f.Cookie, &f.Priority, &f.Reason,
		&f.Table, &f.DurationSec, &f.DurationNSec, &f.IdleTimeout,
		&f.HardTimeout, &f.PacketCount, &f.ByteCount, &f.Match,
	)
}
51530
func (c *PacketConn) ReadFrom(b []byte) (int, net.Addr, error) {
	deadline := c.readCancel()

	var addr tcpip.FullAddress
	read, err := commonRead(c.ep, c.wq, deadline, &addr, c, false)
	if err != nil {
		return 0, nil, err
	}

	return copy(b, read), fullToUDPAddr(addr), nil
}
740532
func (b *reportBuffer) mergeFrom(from *reportBuffer) {
	b.droppedSpanCount += from.droppedSpanCount
	b.logEncoderErrorCount += from.logEncoderErrorCount
	if from.reportStart.Before(b.reportStart) {
		b.reportStart = from.reportStart
	}
	if from.reportEnd.After(b.reportEnd) {
		b.reportEnd = from.reportEnd
	}

	// Note: Somewhat arbitrarily dropping the spans that won't
	// fit; could be more principled here to avoid bias.
	have := len(b.rawSpans)
	space := cap(b.rawSpans) - have
	unreported := len(from.rawSpans)

	if space > unreported {
		space = unreported
	}

	b.rawSpans = append(b.rawSpans, from.rawSpans[0:space]...)

	b.droppedSpanCount += int64(unreported - space)

	from.clear()
}
335621
func (i *InstructionWriteMetadata) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &instruction{},
		&defaultPad4, &i.Metadata, &i.MetadataMask)
}
920327
func (fsc *FSCache) SyncFrom(ctx context.Context, id RemoteIdentifier) (builder.Source, error) { // cacheOpt
	trasportID := id.Transport()
	fsc.mu.Lock()
	transport, ok := fsc.transports[id.Transport()]
	if !ok {
		fsc.mu.Unlock()
		return nil, errors.Errorf("invalid transport %s", trasportID)
	}

	logrus.Debugf("SyncFrom %s %s", id.Key(), id.SharedKey())
	fsc.mu.Unlock()
	sourceRef, err, _ := fsc.g.Do(id.Key(), func() (interface{}, error) {
		var sourceRef *cachedSourceRef
		sourceRef, err := fsc.store.Get(id.Key())
		if err == nil {
			return sourceRef, nil
		}

		// check for unused shared cache
		sharedKey := id.SharedKey()
		if sharedKey != "" {
			r, err := fsc.store.Rebase(sharedKey, id.Key())
			if err == nil {
				sourceRef = r
			}
		}

		if sourceRef == nil {
			var err error
			sourceRef, err = fsc.store.New(id.Key(), sharedKey)
			if err != nil {
				return nil, errors.Wrap(err, "failed to create remote context")
			}
		}

		if err := syncFrom(ctx, sourceRef, transport, id); err != nil {
			sourceRef.Release()
			return nil, err
		}
		if err := sourceRef.resetSize(-1); err != nil {
			return nil, err
		}
		return sourceRef, nil
	})
	if err != nil {
		return nil, err
	}
	ref := sourceRef.(*cachedSourceRef)
	if ref.src == nil { // failsafe
		return nil, errors.Errorf("invalid empty pull")
	}
	wc := &wrappedContext{Source: ref.src, closer: func() error {
		ref.Release()
		return nil
	}}
	return wc, nil
}
1197237
func (entry *Entry) Copy() (*Entry, error) {
	var cdst C.acl_entry_t
	rv, _ := C.acl_copy_entry(cdst, entry.e)
	if rv < 0 {
		return nil, fmt.Errorf("unable to copy entry")
	}
	return &Entry{cdst}, nil
}
791542
func (m *MultipartReply) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &m.Type, &m.Flags, &defaultPad4)
}
403584
func (t *TablePropWildcards) ReadFrom(r io.Reader) (int64, error) {
	return readTablePropXM(r, &t.Fields, nil)
}
196095
func (_m *API) VirtualizationCopyFrom(ctx context.Context, ID string, path string) (io.ReadCloser, string, error) {
	ret := _m.Called(ctx, ID, path)

	var r0 io.ReadCloser
	if rf, ok := ret.Get(0).(func(context.Context, string, string) io.ReadCloser); ok {
		r0 = rf(ctx, ID, path)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(io.ReadCloser)
		}
	}

	var r1 string
	if rf, ok := ret.Get(1).(func(context.Context, string, string) string); ok {
		r1 = rf(ctx, ID, path)
	} else {
		r1 = ret.Get(1).(string)
	}

	var r2 error
	if rf, ok := ret.Get(2).(func(context.Context, string, string) error); ok {
		r2 = rf(ctx, ID, path)
	} else {
		r2 = ret.Error(2)
	}

	return r0, r1, r2
}
155541
func (cli *Client) CopyFromContainer(ctx context.Context, containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) {
	query := make(url.Values, 1)
	query.Set("path", filepath.ToSlash(srcPath)) // Normalize the paths used in the API.

	apiPath := "/containers/" + containerID + "/archive"
	response, err := cli.get(ctx, apiPath, query, nil)
	if err != nil {
		return nil, types.ContainerPathStat{}, wrapResponseError(err, response, "container:path", containerID+":"+srcPath)
	}

	// TODO this code converts non-error status-codes (e.g., "204 No Content") into an error; verify if this is the desired behavior
	if response.statusCode != http.StatusOK {
		return nil, types.ContainerPathStat{}, fmt.Errorf("unexpected status code from daemon: %d", response.statusCode)
	}

	// In order to get the copy behavior right, we need to know information
	// about both the source and the destination. The response headers include
	// stat info about the source that we can use in deciding exactly how to
	// copy it locally. Along with the stat info about the local destination,
	// we have everything we need to handle the multiple possibilities there
	// can be when copying a file/dir from one location to another file/dir.
	stat, err := getContainerPathStatFromHeader(response.header)
	if err != nil {
		return nil, stat, fmt.Errorf("unable to get resource stat from response: %s", err)
	}
	return response.body, stat, err
}
1035841
func (p *SexpHash) CloneFrom(src *SexpHash) {

	p.TypeName = src.TypeName
	p.Map = *(src.CopyMap())

	p.KeyOrder = src.KeyOrder
	p.GoStructFactory = src.GoStructFactory
	p.NumKeys = src.NumKeys
	p.GoMethods = src.GoMethods
	p.GoFields = src.GoFields
	p.GoMethSx = src.GoMethSx
	p.GoFieldSx = src.GoFieldSx
	p.GoType = src.GoType
	p.NumMethod = src.NumMethod
	p.GoShadowStruct = src.GoShadowStruct
	p.GoShadowStructVa = src.GoShadowStructVa
	p.ShadowSet = src.ShadowSet

	// json tag name -> pointers to example values, as factories for SexpToGoStructs()
	p.JsonTagMap = make(map[string]*HashFieldDet)
	for k, v := range src.JsonTagMap {
		p.JsonTagMap[k] = v
	}
	p.DetOrder = src.DetOrder

	// for using these as a scoping model
	p.DefnEnv = src.DefnEnv
	p.SuperClass = src.SuperClass
	p.ZMain = src.ZMain
	p.ZMethods = make(map[string]*SexpFunction)
	for k, v := range src.ZMethods {
		p.ZMethods[k] = v
	}
	p.Env = src.Env
}
1332976
func Copy(xs XStater) XStater {
	if c, ok := xs.(Copier); ok {
		return c.Copy()
	}
	return nop
}
639666
func (r *Store) Copy(ctx context.Context, from, to string) error {
	return r.move(ctx, from, to, false)
}
380914
func (e *Error) ReadFrom(r io.Reader) (n int64, err error) {
	n, err = encoding.ReadFrom(r, &e.Type, &e.Code)
	if err != nil {
		return
	}

	e.Data, err = ioutil.ReadAll(r)
	if err != nil {
		return
	}

	return n + int64(len(e.Data)), nil
}
1321403
func (b *ByteBuffer) ReadFrom(r io.Reader) (int64, error) {
	p := b.B
	nStart := int64(len(p))
	nMax := int64(cap(p))
	n := nStart
	if nMax == 0 {
		nMax = 64
		p = make([]byte, nMax)
	} else {
		p = p[:nMax]
	}
	for {
		if n == nMax {
			nMax *= 2
			bNew := make([]byte, nMax)
			copy(bNew, p)
			p = bNew
		}
		nn, err := r.Read(p[n:])
		n += int64(nn)
		if err != nil {
			b.B = p[:n]
			n -= nStart
			if err == io.EOF {
				return n, nil
			}
			return n, err
		}
	}
}