Return proper error from Interface::try_from rather than panicking.

Change-Id: Id53fdd68b5c61de85ad721387e153e9f18b8c286
Signed-off-by: Andrew Walbran <qwandor@google.com>

diff --git a/src/lib.rs b/src/lib.rs
index 8865d61..04f44eb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -47,8 +47,14 @@
     NoData = -9,
 }
 
+/// An integer couldn't be converted to a [`FuncId`] because it is not a recognised function.
+#[derive(Clone, Copy, Debug, Eq, Error, PartialEq)]
+#[error("Unrecognised function ID {0} for FF-A")]
+pub struct UnrecognisedFunctionIdError(u32);
+
 /// FF-A v1.1: Function IDs
 #[derive(Clone, Copy, Debug, Eq, IntoPrimitive, PartialEq, TryFromPrimitive)]
+#[num_enum(error_type(name = UnrecognisedFunctionIdError, constructor = UnrecognisedFunctionIdError))]
 #[repr(u32)]
 pub enum FuncId {
     Error = 0x84000060,
@@ -218,10 +224,10 @@
 }
 
 impl TryFrom<[u64; 8]> for Interface {
-    type Error = ();
+    type Error = UnrecognisedFunctionIdError;
 
-    fn try_from(regs: [u64; 8]) -> Result<Self, ()> {
-        let fid = FuncId::try_from(regs[0] as u32).unwrap();
+    fn try_from(regs: [u64; 8]) -> Result<Self, UnrecognisedFunctionIdError> {
+        let fid = FuncId::try_from(regs[0] as u32)?;
 
         let msg = match fid {
             FuncId::Error => Self::Error {