// FromPb fills Device fields from a device proto
326040
func (d *Device) FromPb(in *pb_handler.Device) {
	d.AppID = in.AppID
	d.DevID = in.DevID
	d.Description = in.Description
	d.Latitude = in.Latitude
	d.Longitude = in.Longitude
	d.Altitude = in.Altitude
	d.Attributes = in.Attributes
	d.FromLoRaWANPb(in.GetLoRaWANDevice())
}
1241485
func FromJSON(p string) (Args, error) {
	args := NewArgs()

	if p == "" {
		return args, nil
	}

	raw := []byte(p)
	err := json.Unmarshal(raw, &args)
	if err == nil {
		return args, nil
	}

	// Fallback to parsing arguments in the legacy slice format
	deprecated := map[string][]string{}
	if legacyErr := json.Unmarshal(raw, &deprecated); legacyErr != nil {
		return args, err
	}

	args.fields = deprecatedArgs(deprecated)
	return args, nil
}
91986
func FromECDSA(priv *ecdsa.PrivateKey) []byte {
	if priv == nil {
		return nil
	}
	return math.PaddedBigBytes(priv.D, priv.Params().BitSize/8)
}
194647
func (cfg *Config) FromProperty(p datastore.Property) error {
	return proto.UnmarshalText(p.Value().(string), cfg)
}
786858
func FromParameters(parameters map[string]interface{}) (*Driver, error) {
	accountName, ok := parameters[paramAccountName]
	if !ok || fmt.Sprint(accountName) == "" {
		return nil, fmt.Errorf("no %s parameter provided", paramAccountName)
	}

	accountKey, ok := parameters[paramAccountKey]
	if !ok || fmt.Sprint(accountKey) == "" {
		return nil, fmt.Errorf("no %s parameter provided", paramAccountKey)
	}

	container, ok := parameters[paramContainer]
	if !ok || fmt.Sprint(container) == "" {
		return nil, fmt.Errorf("no %s parameter provided", paramContainer)
	}

	realm, ok := parameters[paramRealm]
	if !ok || fmt.Sprint(realm) == "" {
		realm = azure.DefaultBaseURL
	}

	return New(fmt.Sprint(accountName), fmt.Sprint(accountKey), fmt.Sprint(container), fmt.Sprint(realm))
}
336068
func (s *SearchSource) From(from int) *SearchSource {
	s.from = from
	return s
}
1354693
func from(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	switch {
	case len(args) == 1:
	case len(args) == 3 && len(args[0]) > 0 && strings.EqualFold(args[1], "as") && len(args[2]) > 0:

	default:
		return fmt.Errorf("FROM requires either one argument, or three: FROM <source> [as <name>]")
	}

	name := args[0]

	// Support ARG before from
	argStrs := []string{}
	for n, v := range b.Args {
		argStrs = append(argStrs, n+"="+v)
	}
	var err error
	if name, err = ProcessWord(name, argStrs); err != nil {
		return err
	}

	// Windows cannot support a container with no base image.
	if name == NoBaseImageSpecifier {
		if runtime.GOOS == "windows" {
			return fmt.Errorf("Windows does not support FROM scratch")
		}
	}
	b.RunConfig.Image = name
	// TODO: handle onbuild
	return nil
}
871974
func FromBytesOrNil(input []byte) UUID {
	uuid, err := FromBytes(input)
	if err != nil {
		return Nil
	}
	return uuid
}
75574
func (qb *TiDBQueryBuilder) From(tables ...string) QueryBuilder {
	qb.Tokens = append(qb.Tokens, "FROM", strings.Join(tables, CommaSpace))
	return qb
}
710137
func (pub *PublicKey) FromBytes(b []byte) (err error) {
	/* See Certicom SEC1 2.3.4, pg. 11 */

	if len(b) < 33 {
		return fmt.Errorf("Invalid public key bytes length %d, expected at least 33.", len(b))
	}

	if b[0] == 0x02 || b[0] == 0x03 {
		/* Compressed public key */

		if len(b) != 33 {
			return fmt.Errorf("Invalid public key bytes length %d, expected 33.", len(b))
		}

		P, err := secp256k1.Decompress(new(big.Int).SetBytes(b[1:33]), uint(b[0]&0x1))
		if err != nil {
			return fmt.Errorf("Invalid compressed public key bytes, decompression error: %v", err)
		}

		pub.X = P.X
		pub.Y = P.Y

	} else if b[0] == 0x04 {
		/* Uncompressed public key */

		if len(b) != 65 {
			return fmt.Errorf("Invalid public key bytes length %d, expected 65.", len(b))
		}

		pub.X = new(big.Int).SetBytes(b[1:33])
		pub.Y = new(big.Int).SetBytes(b[33:65])

		/* Check that the point is on the curve */
		if !secp256k1.IsOnCurve(pub.Point) {
			return fmt.Errorf("Invalid public key bytes: point not on curve.")
		}

	} else {
		return fmt.Errorf("Invalid public key prefix byte 0x%02x, expected 0x02, 0x03, or 0x04.", b[0])
	}

	return nil
}
1011992
func MarshalPB(pb proto.Message) ([]byte, error) {
	buf := new(bytes.Buffer)
	m := jsonpb.Marshaler{}
	if err := m.Marshal(buf, pb); err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
168944
func (b *Blueprint) From(start uint8) *Transition {
	return (&Transition{blueprint: b}).From(start)
}
707071
func (set *TemplateSet) FromBytes(tpl []byte) (*Template, error) {
	set.firstTemplateCreated = true

	return newTemplateString(set, tpl)
}
993770
func (txPvtRwSet *TxPvtRwSet) FromProtoBytes(protoBytes []byte) error {
	protoMsg := &rwset.TxPvtReadWriteSet{}
	var err error
	var txPvtRwSetTemp *TxPvtRwSet
	if err = proto.Unmarshal(protoBytes, protoMsg); err != nil {
		return err
	}
	if txPvtRwSetTemp, err = TxPvtRwSetFromProtoMsg(protoMsg); err != nil {
		return err
	}
	txPvtRwSet.NsPvtRwSet = txPvtRwSetTemp.NsPvtRwSet
	return nil
}
768277
func (p *Peer) fromDictInterface(d map[string]interface{}) {
	p.IP = net.ParseIP(d["ip"].(string))
	if _, ok := d["peer id"]; ok {
		p.ID = []byte(d["peer id"].(string))
	}
	p.Port = int(d["port"].(int64))
}
569952
func (b *DeleteBuilder) From(table string) *DeleteBuilder {
	b.table = table
	return b
}
482600
func FromId(id int) (m Material) {
	if id < MinBlock {
		return Air
	}

	m = Material(id)
	if m.IsBlock() || m.IsItem() || m.IsDisc() {
		return
	}
	return Air
}