Skip to main content

AnyPdu

Enum AnyPdu 

Source
#[non_exhaustive]
pub enum AnyPdu {
Show 72 variants EntityState(EntityStatePdu), Fire(FirePdu), Detonation(DetonationPdu), Collision(CollisionPdu), ServiceRequest(ServiceRequestPdu), ResupplyOffer(ResupplyOfferPdu), ResupplyReceived(ResupplyReceivedPdu), ResupplyCancel(ResupplyCancelPdu), RepairComplete(RepairCompletePdu), RepairResponse(RepairResponsePdu), CreateEntity(CreateEntityPdu), RemoveEntity(RemoveEntityPdu), StartResume(StartResumePdu), StopFreeze(StopFreezePdu), Acknowledge(AcknowledgePdu), ActionRequest(ActionRequestPdu), ActionResponse(ActionResponsePdu), DataQuery(DataQueryPdu), SetData(SetDataPdu), Data(DataPdu), EventReport(EventReportPdu), Comment(CommentPdu), ElectromagneticEmissions(ElectromagneticEmissionsPdu), Designator(DesignatorPdu), Transmitter(TransmitterPdu), Signal(SignalPdu), Receiver(ReceiverPdu), IFF(IFFPdu), UnderwaterAcoustic(UnderwaterAcousticPdu), SupplementalEmission(SupplementalEmissionPdu), IntercomSignal(IntercomSignalPdu), IntercomControl(IntercomControlPdu), AggregateState(AggregateStatePdu), IsGroupOf(IsGroupOfPdu), TransferOwnership(TransferOwnershipPdu), IsPartOf(IsPartOfPdu), MinefieldState(MinefieldStatePdu), MinefieldQuery(MinefieldQueryPdu), MinefieldData(MinefieldDataPdu), MinefieldResponseNack(MinefieldResponseNackPdu), EnvironmentalProcess(EnvironmentalProcessPdu), GriddedData(GriddedDataPdu), PointObjectState(PointObjectStatePdu), LinearObjectState(LinearObjectStatePdu), ArealObjectState(ArealObjectStatePdu), TimeSpacePositionInformation(TimeSpacePositionInformationPdu), Appearance(AppearancePdu), ArticulatedParts(ArticulatedPartsPdu), LiveEntityFire(LiveEntityFirePdu), LiveEntityDetonation(LiveEntityDetonationPdu), CreateEntityReliable(CreateEntityReliablePdu), RemoveEntityReliable(RemoveEntityReliablePdu), StartResumeReliable(StartResumeReliablePdu), StopFreezeReliable(StopFreezeReliablePdu), AcknowledgeReliable(AcknowledgeReliablePdu), ActionRequestReliable(ActionRequestReliablePdu), ActionResponseReliable(ActionResponseReliablePdu), DataQueryReliable(DataQueryReliablePdu), SetDataReliable(SetDataReliablePdu), DataReliable(DataReliablePdu), EventReportReliable(EventReportReliablePdu), CommentReliable(CommentReliablePdu), RecordReliable(RecordReliablePdu), SetRecordReliable(SetRecordReliablePdu), RecordQueryReliable(RecordQueryReliablePdu), CollisionElastic(CollisionElasticPdu), EntityStateUpdate(EntityStateUpdatePdu), DirectedEnergyFire(DirectedEnergyFirePdu), EntityDamageStatus(EntityDamageStatusPdu), InformationOperationsAction(InformationOperationsActionPdu), InformationOperationsReport(InformationOperationsReportPdu), Attribute(AttributePdu),
}
Expand description

Any PDU, for decoding datagrams whose PDU type isn’t known in advance

Each variant holds one PDU and is named after its PduType. Decode with AnyPdu::deserialize, or AnyPdu::deserialize_all for a datagram that may hold several PDUs, then match on the variants you handle:

use open_dis_rust::{prelude::*, simulation_management::AcknowledgePdu};

let datagram = AcknowledgePdu::new().to_bytes()?;

match AnyPdu::deserialize(&mut datagram.as_slice())? {
    AnyPdu::Acknowledge(ack) => println!("acknowledged request {}", ack.request_id),
    AnyPdu::EntityState(pdu) => println!("entity {:?}", pdu.entity_id),
    other => println!("ignoring {:?} PDU", other.pdu_type()),
}

Every PDU converts into an AnyPdu with From, so PDUs of different types can be kept in one collection and sent with AnyPdu::serialize.

New variants may be added in minor releases, for example for a later version of the standard, so a match needs a wildcard arm.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

EntityState(EntityStatePdu)

§

Fire(FirePdu)

§

Detonation(DetonationPdu)

§

Collision(CollisionPdu)

§

ServiceRequest(ServiceRequestPdu)

§

ResupplyOffer(ResupplyOfferPdu)

§

ResupplyReceived(ResupplyReceivedPdu)

§

ResupplyCancel(ResupplyCancelPdu)

§

RepairComplete(RepairCompletePdu)

§

RepairResponse(RepairResponsePdu)

§

CreateEntity(CreateEntityPdu)

§

RemoveEntity(RemoveEntityPdu)

§

StartResume(StartResumePdu)

§

StopFreeze(StopFreezePdu)

§

Acknowledge(AcknowledgePdu)

§

ActionRequest(ActionRequestPdu)

§

ActionResponse(ActionResponsePdu)

§

DataQuery(DataQueryPdu)

§

SetData(SetDataPdu)

§

Data(DataPdu)

§

EventReport(EventReportPdu)

§

Comment(CommentPdu)

§

ElectromagneticEmissions(ElectromagneticEmissionsPdu)

§

Designator(DesignatorPdu)

§

Transmitter(TransmitterPdu)

§

Signal(SignalPdu)

§

Receiver(ReceiverPdu)

§

IFF(IFFPdu)

§

UnderwaterAcoustic(UnderwaterAcousticPdu)

§

SupplementalEmission(SupplementalEmissionPdu)

§

IntercomSignal(IntercomSignalPdu)

§

IntercomControl(IntercomControlPdu)

§

AggregateState(AggregateStatePdu)

§

IsGroupOf(IsGroupOfPdu)

§

TransferOwnership(TransferOwnershipPdu)

§

IsPartOf(IsPartOfPdu)

§

MinefieldState(MinefieldStatePdu)

§

MinefieldQuery(MinefieldQueryPdu)

§

MinefieldData(MinefieldDataPdu)

§

MinefieldResponseNack(MinefieldResponseNackPdu)

§

EnvironmentalProcess(EnvironmentalProcessPdu)

§

GriddedData(GriddedDataPdu)

§

PointObjectState(PointObjectStatePdu)

§

LinearObjectState(LinearObjectStatePdu)

§

ArealObjectState(ArealObjectStatePdu)

§

TimeSpacePositionInformation(TimeSpacePositionInformationPdu)

§

Appearance(AppearancePdu)

§

ArticulatedParts(ArticulatedPartsPdu)

§

LiveEntityFire(LiveEntityFirePdu)

§

LiveEntityDetonation(LiveEntityDetonationPdu)

§

CreateEntityReliable(CreateEntityReliablePdu)

§

RemoveEntityReliable(RemoveEntityReliablePdu)

§

StartResumeReliable(StartResumeReliablePdu)

§

StopFreezeReliable(StopFreezeReliablePdu)

§

AcknowledgeReliable(AcknowledgeReliablePdu)

§

ActionRequestReliable(ActionRequestReliablePdu)

§

ActionResponseReliable(ActionResponseReliablePdu)

§

DataQueryReliable(DataQueryReliablePdu)

§

SetDataReliable(SetDataReliablePdu)

§

DataReliable(DataReliablePdu)

§

EventReportReliable(EventReportReliablePdu)

§

CommentReliable(CommentReliablePdu)

§

RecordReliable(RecordReliablePdu)

§

SetRecordReliable(SetRecordReliablePdu)

§

RecordQueryReliable(RecordQueryReliablePdu)

§

CollisionElastic(CollisionElasticPdu)

§

EntityStateUpdate(EntityStateUpdatePdu)

§

DirectedEnergyFire(DirectedEnergyFirePdu)

§

EntityDamageStatus(EntityDamageStatusPdu)

§

InformationOperationsAction(InformationOperationsActionPdu)

§

InformationOperationsReport(InformationOperationsReportPdu)

§

Attribute(AttributePdu)

Implementations§

Source§

impl AnyPdu

Source

pub fn pdu_type(&self) -> PduType

The PDU’s type

Source

pub fn protocol_family(&self) -> ProtocolFamily

The PDU’s protocol family

Source

pub fn exercise_id(&self) -> ExerciseIdentifier

The exercise the PDU belongs to, from its header

Source

pub fn serialize(&mut self, buf: &mut Vec<u8>) -> DISResult<()>

Encodes the PDU and appends it to buf, as Pdu::serialize does.

§Errors

Will return DISError in the same cases as Pdu::serialize.

Source§

impl AnyPdu

Source

pub fn deserialize(buf: &mut &[u8]) -> DISResult<Self>

Decodes one PDU of any type from the front of buf, advancing buf past it

The PDU type in the header picks the PDU to decode. As with Pdu::deserialize, exactly the number of octets given by the header’s length field are consumed, so another bundled PDU after it is left in buf. On error, buf is left unchanged.

§Errors

Will return DISError if buf is shorter than a header, its PDU type is not a defined PDU type, or the rest is not a valid PDU of that type.

Source

pub fn deserialize_all( datagram: &[u8], ) -> impl Iterator<Item = DISResult<Self>> + '_

Decodes every PDU in a datagram, which the standard allows to hold several

Each item is the result of AnyPdu::deserialize on what is left of the datagram. When a PDU cannot be decoded, such as one that is malformed or of a PDU type the standard does not define, its error is yielded and decoding carries on after it if its header’s length field fits in the datagram. Otherwise, the error is the last item.

use open_dis_rust::{
    prelude::*,
    simulation_management::{AcknowledgePdu, CommentPdu},
};

let mut datagram = Vec::new();
AcknowledgePdu::new().serialize(&mut datagram)?;
CommentPdu::new().serialize(&mut datagram)?;

for pdu in AnyPdu::deserialize_all(&datagram) {
    println!("{:?}", pdu?.pdu_type());
}
Source

pub fn to_bytes(&mut self) -> DISResult<Vec<u8>>

Encodes the PDU into a new buffer, as Pdu::to_bytes does.

§Errors

Will return DISError in the same cases as Pdu::serialize.

Trait Implementations§

Source§

impl Debug for AnyPdu

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<AcknowledgePdu> for AnyPdu

Source§

fn from(pdu: AcknowledgePdu) -> Self

Converts to this type from the input type.
Source§

impl From<AcknowledgeReliablePdu> for AnyPdu

Source§

fn from(pdu: AcknowledgeReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<ActionRequestPdu> for AnyPdu

Source§

fn from(pdu: ActionRequestPdu) -> Self

Converts to this type from the input type.
Source§

impl From<ActionRequestReliablePdu> for AnyPdu

Source§

fn from(pdu: ActionRequestReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<ActionResponsePdu> for AnyPdu

Source§

fn from(pdu: ActionResponsePdu) -> Self

Converts to this type from the input type.
Source§

impl From<ActionResponseReliablePdu> for AnyPdu

Source§

fn from(pdu: ActionResponseReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<AggregateStatePdu> for AnyPdu

Source§

fn from(pdu: AggregateStatePdu) -> Self

Converts to this type from the input type.
Source§

impl From<AppearancePdu> for AnyPdu

Source§

fn from(pdu: AppearancePdu) -> Self

Converts to this type from the input type.
Source§

impl From<ArealObjectStatePdu> for AnyPdu

Source§

fn from(pdu: ArealObjectStatePdu) -> Self

Converts to this type from the input type.
Source§

impl From<ArticulatedPartsPdu> for AnyPdu

Source§

fn from(pdu: ArticulatedPartsPdu) -> Self

Converts to this type from the input type.
Source§

impl From<AttributePdu> for AnyPdu

Source§

fn from(pdu: AttributePdu) -> Self

Converts to this type from the input type.
Source§

impl From<CollisionElasticPdu> for AnyPdu

Source§

fn from(pdu: CollisionElasticPdu) -> Self

Converts to this type from the input type.
Source§

impl From<CollisionPdu> for AnyPdu

Source§

fn from(pdu: CollisionPdu) -> Self

Converts to this type from the input type.
Source§

impl From<CommentPdu> for AnyPdu

Source§

fn from(pdu: CommentPdu) -> Self

Converts to this type from the input type.
Source§

impl From<CommentReliablePdu> for AnyPdu

Source§

fn from(pdu: CommentReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<CreateEntityPdu> for AnyPdu

Source§

fn from(pdu: CreateEntityPdu) -> Self

Converts to this type from the input type.
Source§

impl From<CreateEntityReliablePdu> for AnyPdu

Source§

fn from(pdu: CreateEntityReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<DataPdu> for AnyPdu

Source§

fn from(pdu: DataPdu) -> Self

Converts to this type from the input type.
Source§

impl From<DataQueryPdu> for AnyPdu

Source§

fn from(pdu: DataQueryPdu) -> Self

Converts to this type from the input type.
Source§

impl From<DataQueryReliablePdu> for AnyPdu

Source§

fn from(pdu: DataQueryReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<DataReliablePdu> for AnyPdu

Source§

fn from(pdu: DataReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<DesignatorPdu> for AnyPdu

Source§

fn from(pdu: DesignatorPdu) -> Self

Converts to this type from the input type.
Source§

impl From<DetonationPdu> for AnyPdu

Source§

fn from(pdu: DetonationPdu) -> Self

Converts to this type from the input type.
Source§

impl From<DirectedEnergyFirePdu> for AnyPdu

Source§

fn from(pdu: DirectedEnergyFirePdu) -> Self

Converts to this type from the input type.
Source§

impl From<ElectromagneticEmissionsPdu> for AnyPdu

Source§

fn from(pdu: ElectromagneticEmissionsPdu) -> Self

Converts to this type from the input type.
Source§

impl From<EntityDamageStatusPdu> for AnyPdu

Source§

fn from(pdu: EntityDamageStatusPdu) -> Self

Converts to this type from the input type.
Source§

impl From<EntityStatePdu> for AnyPdu

Source§

fn from(pdu: EntityStatePdu) -> Self

Converts to this type from the input type.
Source§

impl From<EntityStateUpdatePdu> for AnyPdu

Source§

fn from(pdu: EntityStateUpdatePdu) -> Self

Converts to this type from the input type.
Source§

impl From<EnvironmentalProcessPdu> for AnyPdu

Source§

fn from(pdu: EnvironmentalProcessPdu) -> Self

Converts to this type from the input type.
Source§

impl From<EventReportPdu> for AnyPdu

Source§

fn from(pdu: EventReportPdu) -> Self

Converts to this type from the input type.
Source§

impl From<EventReportReliablePdu> for AnyPdu

Source§

fn from(pdu: EventReportReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<FirePdu> for AnyPdu

Source§

fn from(pdu: FirePdu) -> Self

Converts to this type from the input type.
Source§

impl From<GriddedDataPdu> for AnyPdu

Source§

fn from(pdu: GriddedDataPdu) -> Self

Converts to this type from the input type.
Source§

impl From<IFFPdu> for AnyPdu

Source§

fn from(pdu: IFFPdu) -> Self

Converts to this type from the input type.
Source§

impl From<InformationOperationsActionPdu> for AnyPdu

Source§

fn from(pdu: InformationOperationsActionPdu) -> Self

Converts to this type from the input type.
Source§

impl From<InformationOperationsReportPdu> for AnyPdu

Source§

fn from(pdu: InformationOperationsReportPdu) -> Self

Converts to this type from the input type.
Source§

impl From<IntercomControlPdu> for AnyPdu

Source§

fn from(pdu: IntercomControlPdu) -> Self

Converts to this type from the input type.
Source§

impl From<IntercomSignalPdu> for AnyPdu

Source§

fn from(pdu: IntercomSignalPdu) -> Self

Converts to this type from the input type.
Source§

impl From<IsGroupOfPdu> for AnyPdu

Source§

fn from(pdu: IsGroupOfPdu) -> Self

Converts to this type from the input type.
Source§

impl From<IsPartOfPdu> for AnyPdu

Source§

fn from(pdu: IsPartOfPdu) -> Self

Converts to this type from the input type.
Source§

impl From<LinearObjectStatePdu> for AnyPdu

Source§

fn from(pdu: LinearObjectStatePdu) -> Self

Converts to this type from the input type.
Source§

impl From<LiveEntityDetonationPdu> for AnyPdu

Source§

fn from(pdu: LiveEntityDetonationPdu) -> Self

Converts to this type from the input type.
Source§

impl From<LiveEntityFirePdu> for AnyPdu

Source§

fn from(pdu: LiveEntityFirePdu) -> Self

Converts to this type from the input type.
Source§

impl From<MinefieldDataPdu> for AnyPdu

Source§

fn from(pdu: MinefieldDataPdu) -> Self

Converts to this type from the input type.
Source§

impl From<MinefieldQueryPdu> for AnyPdu

Source§

fn from(pdu: MinefieldQueryPdu) -> Self

Converts to this type from the input type.
Source§

impl From<MinefieldResponseNackPdu> for AnyPdu

Source§

fn from(pdu: MinefieldResponseNackPdu) -> Self

Converts to this type from the input type.
Source§

impl From<MinefieldStatePdu> for AnyPdu

Source§

fn from(pdu: MinefieldStatePdu) -> Self

Converts to this type from the input type.
Source§

impl From<PointObjectStatePdu> for AnyPdu

Source§

fn from(pdu: PointObjectStatePdu) -> Self

Converts to this type from the input type.
Source§

impl From<ReceiverPdu> for AnyPdu

Source§

fn from(pdu: ReceiverPdu) -> Self

Converts to this type from the input type.
Source§

impl From<RecordQueryReliablePdu> for AnyPdu

Source§

fn from(pdu: RecordQueryReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<RecordReliablePdu> for AnyPdu

Source§

fn from(pdu: RecordReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<RemoveEntityPdu> for AnyPdu

Source§

fn from(pdu: RemoveEntityPdu) -> Self

Converts to this type from the input type.
Source§

impl From<RemoveEntityReliablePdu> for AnyPdu

Source§

fn from(pdu: RemoveEntityReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<RepairCompletePdu> for AnyPdu

Source§

fn from(pdu: RepairCompletePdu) -> Self

Converts to this type from the input type.
Source§

impl From<RepairResponsePdu> for AnyPdu

Source§

fn from(pdu: RepairResponsePdu) -> Self

Converts to this type from the input type.
Source§

impl From<ResupplyCancelPdu> for AnyPdu

Source§

fn from(pdu: ResupplyCancelPdu) -> Self

Converts to this type from the input type.
Source§

impl From<ResupplyOfferPdu> for AnyPdu

Source§

fn from(pdu: ResupplyOfferPdu) -> Self

Converts to this type from the input type.
Source§

impl From<ResupplyReceivedPdu> for AnyPdu

Source§

fn from(pdu: ResupplyReceivedPdu) -> Self

Converts to this type from the input type.
Source§

impl From<ServiceRequestPdu> for AnyPdu

Source§

fn from(pdu: ServiceRequestPdu) -> Self

Converts to this type from the input type.
Source§

impl From<SetDataPdu> for AnyPdu

Source§

fn from(pdu: SetDataPdu) -> Self

Converts to this type from the input type.
Source§

impl From<SetDataReliablePdu> for AnyPdu

Source§

fn from(pdu: SetDataReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<SetRecordReliablePdu> for AnyPdu

Source§

fn from(pdu: SetRecordReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<SignalPdu> for AnyPdu

Source§

fn from(pdu: SignalPdu) -> Self

Converts to this type from the input type.
Source§

impl From<StartResumePdu> for AnyPdu

Source§

fn from(pdu: StartResumePdu) -> Self

Converts to this type from the input type.
Source§

impl From<StartResumeReliablePdu> for AnyPdu

Source§

fn from(pdu: StartResumeReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<StopFreezePdu> for AnyPdu

Source§

fn from(pdu: StopFreezePdu) -> Self

Converts to this type from the input type.
Source§

impl From<StopFreezeReliablePdu> for AnyPdu

Source§

fn from(pdu: StopFreezeReliablePdu) -> Self

Converts to this type from the input type.
Source§

impl From<SupplementalEmissionPdu> for AnyPdu

Source§

fn from(pdu: SupplementalEmissionPdu) -> Self

Converts to this type from the input type.
Source§

impl From<TimeSpacePositionInformationPdu> for AnyPdu

Source§

fn from(pdu: TimeSpacePositionInformationPdu) -> Self

Converts to this type from the input type.
Source§

impl From<TransferOwnershipPdu> for AnyPdu

Source§

fn from(pdu: TransferOwnershipPdu) -> Self

Converts to this type from the input type.
Source§

impl From<TransmitterPdu> for AnyPdu

Source§

fn from(pdu: TransmitterPdu) -> Self

Converts to this type from the input type.
Source§

impl From<UnderwaterAcousticPdu> for AnyPdu

Source§

fn from(pdu: UnderwaterAcousticPdu) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Forget for AnyPdu

§

impl Freeze for AnyPdu

§

impl Move for AnyPdu

§

impl RefUnwindSafe for AnyPdu

§

impl Send for AnyPdu

§

impl Sync for AnyPdu

§

impl Unpin for AnyPdu

§

impl UnsafeUnpin for AnyPdu

§

impl UnwindSafe for AnyPdu

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.