@Stebalien First off, thank you for maintaining this wonderful library. :-)
I came across a particular issue with the current API. Specifically, TerminfoTerminal::new_with_terminfo takes ownership over a TermInfo. Even though TermInfo is never mutated by a TerminfoTerminal, a TermInfo cannot be reused across multiple TerminfoTerminal values. In particular, the only way to amortize the cost of building a TermInfo is to clone it, but even this can be costly.
I'm not sure what the right API is, but I will note that using Arc solves my specific problem (which permits very cheap multithreaded read-only access).
There are potentially many other solutions, all with their own downsides:
- Require
Arc<TermInfo> instead of TermInfo, but this feels a little strange to me.
- Require
<T: AsRef<TermInfo>>. This means TermInfoTerminal will need to grow a type parameter.
- Define a new trait with the existing methods on
TermInfo and require that. This also requires an additional type parameter.
- Make
TermInfo an opaque struct and use an Arc internally, which will make cloning trivially cheap.
Other ideas? Thoughts?
@Stebalien First off, thank you for maintaining this wonderful library. :-)
I came across a particular issue with the current API. Specifically,
TerminfoTerminal::new_with_terminfotakes ownership over aTermInfo. Even thoughTermInfois never mutated by aTerminfoTerminal, aTermInfocannot be reused across multipleTerminfoTerminalvalues. In particular, the only way to amortize the cost of building aTermInfois tocloneit, but even this can be costly.I'm not sure what the right API is, but I will note that using
Arcsolves my specific problem (which permits very cheap multithreaded read-only access).There are potentially many other solutions, all with their own downsides:
Arc<TermInfo>instead ofTermInfo, but this feels a little strange to me.<T: AsRef<TermInfo>>. This meansTermInfoTerminalwill need to grow a type parameter.TermInfoand require that. This also requires an additional type parameter.TermInfoan opaque struct and use anArcinternally, which will make cloning trivially cheap.Other ideas? Thoughts?