Skip to content

Support for DecodeWithMemTracking with Cow<'static, str> #734

@dimartiro

Description

@dimartiro

I having some issues when trying to add DecodeWithMemTracking in an enum with Cow<'static, str>

#[cfg_attr(
	feature = "with-codec",
	derive(
		scale_codec::Encode,
		scale_codec::Decode,
		scale_codec::DecodeWithMemTracking,
		scale_info::TypeInfo
	)
)]
pub enum ExitFatal {
	/// The operation is not supported.
	NotSupported,
	/// The trap (interrupt) is unhandled.
	UnhandledInterrupt,
	/// The environment explicitly set call errors as fatal error.
	CallErrorAsFatal(ExitError),

	/// Other fatal errors.
	Other(Cow<'static, str>),
}

The error is:

the trait `DecodeWithMemTracking` is not implemented for `str`, which is required by `Cow<'static, str>: DecodeWithMemTracking

Is there any way to support this without replacing the Cow<'static, str> to String?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions