MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / to_vec

Method to_vec

lrwn/src/maccommand.rs:429–628  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

427 }
428
429 pub fn to_vec(&self) -> Result<Vec<u8>> {
430 let mut out = Vec::new();
431
432 for mac in &self.0 {
433 match mac {
434 // LoRaWAN
435 MACCommand::ResetInd(pl) => {
436 out.push(mac.cid().to_u8());
437 out.extend_from_slice(&pl.encode()?);
438 }
439 MACCommand::ResetConf(pl) => {
440 out.push(mac.cid().to_u8());
441 out.extend_from_slice(&pl.encode()?);
442 }
443 MACCommand::LinkCheckReq => {
444 out.push(mac.cid().to_u8());
445 }
446 MACCommand::LinkCheckAns(pl) => {
447 out.push(mac.cid().to_u8());
448 out.extend_from_slice(&pl.encode()?);
449 }
450 MACCommand::LinkADRReq(pl) => {
451 out.push(mac.cid().to_u8());
452 out.extend_from_slice(&pl.encode()?);
453 }
454 MACCommand::LinkADRAns(pl) => {
455 out.push(mac.cid().to_u8());
456 out.extend_from_slice(&pl.encode()?);
457 }
458 MACCommand::DutyCycleReq(pl) => {
459 out.push(mac.cid().to_u8());
460 out.extend_from_slice(&pl.encode()?);
461 }
462 MACCommand::DutyCycleAns => {
463 out.push(mac.cid().to_u8());
464 }
465 MACCommand::RxParamSetupReq(pl) => {
466 out.push(mac.cid().to_u8());
467 out.extend_from_slice(&pl.encode()?);
468 }
469 MACCommand::RxParamSetupAns(pl) => {
470 out.push(mac.cid().to_u8());
471 out.extend_from_slice(&pl.encode()?);
472 }
473 MACCommand::DevStatusReq => {
474 out.push(mac.cid().to_u8());
475 }
476 MACCommand::DevStatusAns(pl) => {
477 out.push(mac.cid().to_u8());
478 out.extend_from_slice(&pl.encode()?);
479 }
480 MACCommand::NewChannelReq(pl) => {
481 out.push(mac.cid().to_u8());
482 out.extend_from_slice(&pl.encode()?);
483 }
484 MACCommand::NewChannelAns(pl) => {
485 out.push(mac.cid().to_u8());
486 out.extend_from_slice(&pl.encode()?);

Callers 3

sizeMethod · 0.45
decode_from_rawMethod · 0.45
encodeMethod · 0.45

Calls 4

pushMethod · 0.80
to_u8Method · 0.45
cidMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected