Trait levana_perpswap_cosmos::prelude::Display
1.0.0 · source · pub trait Display {
// Required method
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>;
}
Expand description
Format trait for an empty format, {}
.
Implementing this trait for a type will automatically implement the
ToString
trait for the type, allowing the usage
of the .to_string()
method. Prefer implementing
the Display
trait for a type, rather than ToString
.
Display
is similar to Debug
, but Display
is for user-facing
output, and so cannot be derived.
For more information on formatters, see the module-level documentation.
§Internationalization
Because a type can only have one Display
implementation, it is often preferable
to only implement Display
when there is a single most “obvious” way that
values can be formatted as text. This could mean formatting according to the
“invariant” culture and “undefined” locale, or it could mean that the type
display is designed for a specific culture/locale, such as developer logs.
If not all values have a justifiably canonical textual format or if you want
to support alternative formats not covered by the standard set of possible
formatting traits, the most flexible approach is display adapters: methods
like str::escape_default
or Path::display
which create a wrapper
implementing Display
to output the specific display format.
§Examples
Implementing Display
on a type:
use std::fmt;
struct Point {
x: i32,
y: i32,
}
impl fmt::Display for Point {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({}, {})", self.x, self.y)
}
}
let origin = Point { x: 0, y: 0 };
assert_eq!(format!("The origin is: {origin}"), "The origin is: (0, 0)");
Required Methods§
1.0.0 · sourcefn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Formats the value using the given formatter.
§Errors
This function should return Err
if, and only if, the provided Formatter
returns Err
.
String formatting is considered an infallible operation; this function only
returns a Result
because writing to the underlying stream might fail and it must
provide a way to propagate the fact that an error has occurred back up the stack.
§Examples
use std::fmt;
struct Position {
longitude: f32,
latitude: f32,
}
impl fmt::Display for Position {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({}, {})", self.longitude, self.latitude)
}
}
assert_eq!(
"(1.987, 2.983)",
format!("{}", Position { longitude: 1.987, latitude: 2.983, }),
);
Implementors§
impl Display for FailedReason
impl Display for levana_perpswap_cosmos::contracts::copy_trading::Token
impl Display for levana_perpswap_cosmos::contracts::countertrade::Token
impl Display for WorkDescription
impl Display for PositionActionKind
impl Display for LiquidationReason
impl Display for PositionCloseReason
impl Display for MaxGainsInQuote
impl Display for TakeProfitTrader
impl Display for AuthCheck
impl Display for MarketError
impl Display for TriggerPriceMustBe
impl Display for TriggerType
impl Display for AsciiChar
impl Display for Infallible
impl Display for IpAddr
impl Display for SocketAddr
impl Display for VarError
impl Display for std::io::error::ErrorKind
impl Display for RecvTimeoutError
impl Display for TryRecvError
impl Display for FromHexError
impl Display for Value
impl Display for BernoulliError
impl Display for bool
impl Display for char
impl Display for f32
impl Display for f64
impl Display for i8
impl Display for i16
impl Display for i32
impl Display for i64
impl Display for i128
impl Display for isize
impl Display for !
impl Display for str
impl Display for u8
impl Display for u16
impl Display for u32
impl Display for u64
impl Display for u128
impl Display for usize
impl Display for DecQueuePositionId
impl Display for IncQueuePositionId
impl Display for Cw20Coin
impl Display for Cw20CoinVerified
impl Display for DeferredExecId
impl Display for OrderId
impl Display for PositionId
impl Display for LeverageToBase
impl Display for SignedLeverageToBase
impl Display for MarketId
impl Display for Base
impl Display for Collateral
impl Display for FarmingToken
impl Display for LpToken
impl Display for LvnToken
impl Display for Notional
impl Display for Quote
impl Display for Usd
impl Display for Price
impl Display for PriceBaseInQuote
impl Display for PriceCollateralInUsd
impl Display for levana_perpswap_cosmos::time::Timestamp
impl Display for UnorderedKeyError
impl Display for TryReserveError
impl Display for FromVecWithNulError
impl Display for IntoStringError
impl Display for NulError
impl Display for FromUtf8Error
impl Display for FromUtf16Error
impl Display for String
impl Display for LayoutError
impl Display for core::alloc::AllocError
impl Display for TryFromSliceError
impl Display for core::ascii::EscapeDefault
impl Display for BorrowError
impl Display for BorrowMutError
impl Display for CharTryFromError
impl Display for ParseCharError
impl Display for DecodeUtf16Error
impl Display for core::char::EscapeDebug
impl Display for core::char::EscapeDefault
impl Display for core::char::EscapeUnicode
impl Display for ToLowercase
impl Display for ToUppercase
impl Display for TryFromCharError
impl Display for FromBytesUntilNulError
impl Display for FromBytesWithNulError
impl Display for Arguments<'_>
impl Display for core::fmt::Error
impl Display for Ipv4Addr
impl Display for Ipv6Addr
Write an Ipv6Addr, conforming to the canonical style described by RFC 5952.
impl Display for AddrParseError
impl Display for SocketAddrV4
impl Display for SocketAddrV6
impl Display for core::num::dec2flt::ParseFloatError
impl Display for core::num::error::ParseIntError
impl Display for core::num::error::TryFromIntError
impl Display for Location<'_>
impl Display for PanicInfo<'_>
impl Display for PanicMessage<'_>
impl Display for ParseBoolError
impl Display for Utf8Error
impl Display for TryFromFloatSecsError
impl Display for Backtrace
impl Display for JoinPathsError
impl Display for std::ffi::os_str::Display<'_>
impl Display for WriterPanicked
impl Display for std::io::error::Error
impl Display for PanicHookInfo<'_>
impl Display for std::path::Display<'_>
impl Display for StripPrefixError
impl Display for ExitStatus
impl Display for ExitStatusError
impl Display for RecvError
impl Display for AccessError
impl Display for SystemTimeError
impl Display for anyhow::Error
impl Display for getrandom::error::Error
impl Display for num_bigint::bigint::BigInt
impl Display for BigUint
impl Display for ParseBigIntError
impl Display for num_traits::ParseFloatError
impl Display for semver::parse::Error
impl Display for BuildMetadata
impl Display for Comparator
impl Display for Prerelease
impl Display for Version
impl Display for VersionReq
impl Display for serde::de::value::Error
impl Display for serde_json::error::Error
impl Display for Number
impl Display for rand_core::error::Error
impl Display for Addr
impl Display for Decimal256
impl Display for RawAddr
impl Display for Uint64
impl Display for Aggregation
impl Display for AggregationError
impl Display for AllocError
impl Display for Binary
impl Display for CanonicalAddr
impl Display for CharError
impl Display for CheckedFromRatioError
impl Display for CheckedHrpstringError
impl Display for CheckedMultiplyFractionError
impl Display for CheckedMultiplyRatioError
impl Display for Checksum
impl Display for ChecksumError
impl Display for ChecksumError
impl Display for Class
impl Display for CodeLengthError
impl Display for Coin
impl Display for CoinFromStrError
impl Display for Coins
impl Display for CoinsError
impl Display for ConversionOverflowError
impl Display for CryptoError
impl Display for DateTime
impl Display for Decimal
impl Display for Decimal256RangeExceeded
impl Display for DecimalRangeExceeded
impl Display for DecodeError
impl Display for DecodeError
impl Display for DecodeError
impl Display for DecodeSliceError
impl Display for DivideByZeroError
impl Display for DivisionError
impl Display for Duration
impl Display for EncodeError
impl Display for EncodeError
impl Display for EncodeIoError
impl Display for EncodeSliceError
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for ErrorKind
impl Display for Expiration
impl Display for Fe32
impl Display for FromCharError
impl Display for HashToCurveError
impl Display for HexBinary
impl Display for HexDisplay<'_>
impl Display for Hrp
Displays the human-readable part.
If an uppercase HRP was parsed during object construction then the returned string will be
in uppercase also. For a lowercase string see Self::to_lowercase
.
impl Display for Identifier
impl Display for Instantiate2AddressError
impl Display for Int64
impl Display for Int128
impl Display for Int256
impl Display for Int512
impl Display for IntegrityError
impl Display for IntegrityError
impl Display for InvalidBufferSize
impl Display for InvalidLength
impl Display for InvalidOutputSize
impl Display for InvalidWitnessVersionError
impl Display for Length
impl Display for Limb
impl Display for MacError
impl Display for NativeBalance
impl Display for Never
impl Display for ObjectIdentifier
impl Display for OverflowError
impl Display for OverflowOperation
impl Display for PaddingError
impl Display for PairingEquality
impl Display for PairingEqualityError
impl Display for ParseAlphabetError
impl Display for ParseIntError
impl Display for ParseReplyError
impl Display for PaymentError
impl Display for PythContractError
impl Display for RecoverPubkeyError
impl Display for RoundDownOverflowError
impl Display for RoundUpOverflowError
impl Display for Scheduled
impl Display for SegwitCodeLengthError
impl Display for SegwitHrpstringError
impl Display for SerializationError
impl Display for Signature
impl Display for SignedDecimal
impl Display for SignedDecimal256
impl Display for SignedDecimal256RangeExceeded
impl Display for SignedDecimalRangeExceeded
impl Display for StdError
impl Display for SystemError
impl Display for Tag
impl Display for TagMode
impl Display for TagNumber
impl Display for ThreadPoolBuildError
impl Display for ThresholdError
impl Display for Timestamp
impl Display for TryFromError
impl Display for TryFromIntError
impl Display for Uint128
impl Display for Uint256
impl Display for Uint512
impl Display for UncheckedHrpstringError
impl Display for VerificationError
impl Display for VersionError
impl Display for WitnessLengthError
impl Display for dyn Expected + '_
impl<'a> Display for Unexpected<'a>
impl<'a> Display for EscapeAscii<'a>
impl<'a> Display for core::str::iter::EscapeDebug<'a>
impl<'a> Display for core::str::iter::EscapeDefault<'a>
impl<'a> Display for core::str::iter::EscapeUnicode<'a>
impl<'a> Display for Ia5StringRef<'a>
impl<'a> Display for PrintableStringRef<'a>
impl<'a> Display for TeletexStringRef<'a>
impl<'a> Display for Utf8StringRef<'a>
impl<'a> Display for VideotexStringRef<'a>
impl<'a, 'e, E> Display for Base64Display<'a, 'e, E>where
E: Engine,
impl<'a, I> Display for Format<'a, I>
impl<'a, I, F> Display for FormatWith<'a, I, F>
impl<'a, K, V> Display for std::collections::hash::map::OccupiedError<'a, K, V>
impl<'a, K, V, A> Display for alloc::collections::btree::map::entry::OccupiedError<'a, K, V, A>
impl<'a, K, V, S, A> Display for OccupiedError<'a, K, V, S, A>
impl<'a, K, V, S, A> Display for OccupiedError<'a, K, V, S, A>
impl<B> Display for Cow<'_, B>
impl<C> Display for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> Display for ScalarPrimitive<C>where
C: Curve,
impl<C> Display for Signature<C>
impl<E> Display for Report<E>where
E: Error,
impl<F> Display for FormatterFn<F>
impl<I> Display for ExactlyOneError<I>where
I: Iterator,
impl<L, R> Display for Either<L, R>
impl<O> Display for F32<O>where
O: ByteOrder,
impl<O> Display for F64<O>where
O: ByteOrder,
impl<O> Display for I16<O>where
O: ByteOrder,
impl<O> Display for I32<O>where
O: ByteOrder,
impl<O> Display for I64<O>where
O: ByteOrder,
impl<O> Display for I128<O>where
O: ByteOrder,
impl<O> Display for U16<O>where
O: ByteOrder,
impl<O> Display for U32<O>where
O: ByteOrder,
impl<O> Display for U64<O>where
O: ByteOrder,
impl<O> Display for U128<O>where
O: ByteOrder,
impl<P> Display for Affine<P>where
P: SWCurveConfig,
impl<P> Display for Affine<P>where
P: TECurveConfig,
impl<P> Display for CubicExtField<P>where
P: CubicExtConfig,
impl<P> Display for MontgomeryAffine<P>where
P: MontCurveConfig,
impl<P> Display for PairingOutput<P>where
P: Pairing,
impl<P> Display for Projective<P>where
P: SWCurveConfig,
impl<P> Display for Projective<P>where
P: TECurveConfig,
impl<P> Display for QuadExtField<P>where
P: QuadExtConfig,
impl<P, const N: usize> Display for Fp<P, N>where
P: FpConfig<N>,
Outputs a string containing the value of self
,
represented as a decimal without leading zeroes.