Skip to content

Commit

Permalink
tweak: ContextualFormat takes a fmt::Formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
dhedey committed Nov 26, 2024
1 parent 0e3a869 commit 1b5c173
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 50 deletions.
4 changes: 2 additions & 2 deletions radix-common/src/types/addresses/component_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ impl fmt::Debug for ComponentAddress {
impl<'a> ContextualDisplay<AddressDisplayContext<'a>> for ComponentAddress {
type Error = AddressBech32EncodeError;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &AddressDisplayContext<'a>,
) -> Result<(), Self::Error> {
if let Some(encoder) = context.encoder {
Expand Down
4 changes: 2 additions & 2 deletions radix-common/src/types/addresses/global_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ impl fmt::Debug for GlobalAddress {
impl<'a> ContextualDisplay<AddressDisplayContext<'a>> for GlobalAddress {
type Error = AddressBech32EncodeError;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &AddressDisplayContext<'a>,
) -> Result<(), Self::Error> {
if let Some(encoder) = context.encoder {
Expand Down
4 changes: 2 additions & 2 deletions radix-common/src/types/addresses/internal_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ impl fmt::Debug for InternalAddress {
impl<'a> ContextualDisplay<AddressDisplayContext<'a>> for InternalAddress {
type Error = AddressBech32EncodeError;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &AddressDisplayContext<'a>,
) -> Result<(), Self::Error> {
if let Some(encoder) = context.encoder {
Expand Down
4 changes: 2 additions & 2 deletions radix-common/src/types/addresses/package_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ impl fmt::Debug for PackageAddress {
impl<'a> ContextualDisplay<AddressDisplayContext<'a>> for PackageAddress {
type Error = AddressBech32EncodeError;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &AddressDisplayContext<'a>,
) -> Result<(), Self::Error> {
if let Some(encoder) = context.encoder {
Expand Down
4 changes: 2 additions & 2 deletions radix-common/src/types/addresses/resource_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ impl fmt::Debug for ResourceAddress {
impl<'a> ContextualDisplay<AddressDisplayContext<'a>> for ResourceAddress {
type Error = AddressBech32EncodeError;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &AddressDisplayContext<'a>,
) -> Result<(), Self::Error> {
if let Some(encoder) = context.encoder {
Expand Down
4 changes: 2 additions & 2 deletions radix-common/src/types/blueprint_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ impl BlueprintId {
impl<'a> ContextualDisplay<AddressDisplayContext<'a>> for BlueprintId {
type Error = fmt::Error;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &AddressDisplayContext<'a>,
) -> Result<(), Self::Error> {
write!(
Expand Down
4 changes: 2 additions & 2 deletions radix-common/src/types/node_and_substate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ impl Debug for NodeId {
impl<'a> ContextualDisplay<AddressDisplayContext<'a>> for NodeId {
type Error = AddressBech32EncodeError;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &AddressDisplayContext<'a>,
) -> Result<(), Self::Error> {
if let Some(encoder) = context.encoder {
Expand Down
4 changes: 2 additions & 2 deletions radix-common/src/types/non_fungible_global_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ impl fmt::Display for ParseNonFungibleGlobalIdError {
impl<'a> ContextualDisplay<AddressDisplayContext<'a>> for NonFungibleGlobalId {
type Error = fmt::Error;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &AddressDisplayContext<'a>,
) -> Result<(), Self::Error> {
write!(
Expand Down
4 changes: 2 additions & 2 deletions radix-engine-interface/src/types/event_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ pub enum Emitter {
impl<'a> ContextualDisplay<AddressDisplayContext<'a>> for Emitter {
type Error = fmt::Error;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &AddressDisplayContext<'a>,
) -> Result<(), Self::Error> {
match self {
Expand Down
4 changes: 2 additions & 2 deletions radix-engine-interface/src/types/indexed_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ impl<'s, 'a> ContextualDisplay<ValueDisplayParameters<'s, 'a, ScryptoCustomExten
{
type Error = sbor::representations::FormattingError;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &ValueDisplayParameters<'_, '_, ScryptoCustomExtension>,
) -> Result<(), Self::Error> {
ScryptoRawPayload::new_from_valid_slice(self.as_slice()).format(f, *context)
Expand Down
4 changes: 2 additions & 2 deletions radix-engine-interface/src/types/invocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ pub struct FnIdentifier {
impl<'a> ContextualDisplay<AddressDisplayContext<'a>> for FnIdentifier {
type Error = fmt::Error;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &AddressDisplayContext<'a>,
) -> Result<(), Self::Error> {
write!(
Expand Down
16 changes: 8 additions & 8 deletions radix-engine/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ pub enum RejectionReason {
impl<'a> ContextualDisplay<ScryptoValueDisplayContext<'a>> for RejectionReason {
type Error = fmt::Error;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &ScryptoValueDisplayContext,
) -> Result<(), Self::Error> {
self.create_persistable().contextual_format(f, context)
Expand All @@ -172,9 +172,9 @@ impl<'a> ContextualDisplay<ScryptoValueDisplayContext<'a>> for PersistableReject
type Error = fmt::Error;

/// See [`SerializableRuntimeError::contextual_format`] for more information.
fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &ScryptoValueDisplayContext,
) -> Result<(), Self::Error> {
let value = &self.encoded_rejection_reason;
Expand Down Expand Up @@ -339,9 +339,9 @@ pub enum RuntimeError {
impl<'a> ContextualDisplay<ScryptoValueDisplayContext<'a>> for RuntimeError {
type Error = fmt::Error;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &ScryptoValueDisplayContext,
) -> Result<(), Self::Error> {
self.create_persistable().contextual_format(f, context)
Expand Down Expand Up @@ -383,9 +383,9 @@ pub struct PersistableRuntimeError {
impl<'a> ContextualDisplay<ScryptoValueDisplayContext<'a>> for PersistableRuntimeError {
type Error = fmt::Error;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &ScryptoValueDisplayContext,
) -> Result<(), Self::Error> {
let value = &self.encoded_error;
Expand Down
8 changes: 4 additions & 4 deletions radix-engine/src/transaction/transaction_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,9 +1020,9 @@ impl<'a> TransactionReceiptDisplayContextBuilder<'a> {
impl<'a> ContextualDisplay<TransactionReceiptDisplayContext<'a>> for TransactionReceipt {
type Error = fmt::Error;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &TransactionReceiptDisplayContext<'a>,
) -> Result<(), Self::Error> {
let result = &self.result;
Expand Down Expand Up @@ -1195,9 +1195,9 @@ impl<'a, 'b> ContextualDisplay<TransactionReceiptDisplayContext<'a>>
{
type Error = fmt::Error;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &TransactionReceiptDisplayContext<'a>,
) -> Result<(), Self::Error> {
let state_updates = self.0;
Expand Down
8 changes: 4 additions & 4 deletions radix-rust/src/contextual_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pub trait ContextualDisplay<Context> {
/// instead of a `&Context`.
///
/// [`format`]: #method.format
fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &Context,
) -> Result<(), Self::Error>;

Expand All @@ -34,9 +34,9 @@ pub trait ContextualDisplay<Context> {
///
/// [`contextual_format`]: #method.contextual_format
/// [`display`]: #method.display
fn format<F: fmt::Write, TContext: Into<Context>>(
fn format<TContext: Into<Context>>(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: TContext,
) -> Result<(), Self::Error> {
self.contextual_format(f, &context.into())
Expand Down
4 changes: 2 additions & 2 deletions radix-transaction-scenarios/src/scenario.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ pub enum DescribedAddress {
impl<'a> ContextualDisplay<AddressDisplayContext<'a>> for DescribedAddress {
type Error = fmt::Error;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &AddressDisplayContext<'a>,
) -> Result<(), Self::Error> {
match self {
Expand Down
8 changes: 4 additions & 4 deletions radix-transactions/src/data/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ impl<'a> Into<ManifestDecompilationDisplayContext<'a>> for Option<&'a AddressBec
impl<'a> ContextualDisplay<ManifestDecompilationDisplayContext<'a>> for ManifestValue {
type Error = fmt::Error;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &ManifestDecompilationDisplayContext<'a>,
) -> Result<(), Self::Error> {
format_manifest_value(f, self, context, false, 0)
Expand Down Expand Up @@ -515,9 +515,9 @@ impl<'a> fmt::Display for DisplayableManifestValueKind<'a> {
impl<'a> ContextualDisplay<ManifestDecompilationDisplayContext<'a>> for ManifestCustomValue {
type Error = fmt::Error;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &ManifestDecompilationDisplayContext<'a>,
) -> Result<(), Self::Error> {
format_custom_value(f, self, context, false, 0)
Expand Down
4 changes: 2 additions & 2 deletions radix-transactions/src/model/hash/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ macro_rules! impl_contextual_display {
impl<'a> ContextualDisplay<TransactionHashDisplayContext<'a>> for $type {
type Error = fmt::Error;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
context: &TransactionHashDisplayContext<'a>,
) -> Result<(), Self::Error> {
if let Some(encoder) = context.encoder {
Expand Down
8 changes: 4 additions & 4 deletions sbor/src/representations/display/contextual_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ impl<'s, 'a, 'b, E: FormattableCustomExtension> ContextualDisplay<ValueDisplayPa
{
type Error = FormattingError;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
options: &ValueDisplayParameters<'s, 'a, E>,
) -> Result<(), Self::Error> {
let context = options.get_context_and_type_id();
Expand Down Expand Up @@ -171,9 +171,9 @@ impl<'s, 'a, 'b, E: FormattableCustomExtension> ContextualDisplay<ValueDisplayPa
{
type Error = FormattingError;

fn contextual_format<F: fmt::Write>(
fn contextual_format(
&self,
f: &mut F,
f: &mut fmt::Formatter,
options: &ValueDisplayParameters<'s, 'a, E>,
) -> Result<(), Self::Error> {
let context = options.get_context_and_type_id();
Expand Down

0 comments on commit 1b5c173

Please sign in to comment.