Enable all functions to work on element of new type

If I make a new struct that contains a certain type (a DataFrame in below example) like:

struct StructContainingDataFrame

Is it then possible to make this work with all functions that are defined for a DataFrame input. In other words is it possible to get something like this to work:

function fff(x::StructContainingDataFrame) where fff in [DataFrames.nrow, DataFrames.ncol and all other 1d dataframes functions]

where in the above case I would hope that any function supporting dataframes would also support my new struct.

Guess its only possible, if DataFrames does not rely on duck-typing, i.e., defines an abstract type (or a trait) that you could subtype.

On the other hand, what should those functions do on your new type? If you just forward them as in your example, i.e., fff(x.df), the result would lose your type and something_else immediately after a single call. Thus, you might want to wrap via fff(x::StructContainingDataFrame) = StructContainingDataFrame(fff(x.df), something_else) and would need to redefine every function anyways.

PS: Seems that DataFrames does define AbstractDataFrame, but I don’t know which minimal interface is required to make all other methods defined for AbstractDataFrame work on your type.

See here

And the other thread linked therein.

For the specific example maybe go the other way and store whatever else you need a metadata of the DataFrame?