{-# LANGUAGE DeriveDataTypeable #-}
{-# OPTIONS_GHC -fno-warn-missing-fields #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-----------------------------------------------------------------
-- Autogenerated by Thrift Compiler (0.7.0-dev)                      --
--                                                             --
-- DO NOT EDIT UNLESS YOU ARE SURE YOU KNOW WHAT YOU ARE DOING --
-----------------------------------------------------------------

module Thrift.ContentProvider_Client(downloadMesh) where
import Data.IORef
import Prelude ( Bool(..), Enum, Double, String, Maybe(..),
                 Eq, Show, Ord,
                 return, length, IO, fromIntegral, fromEnum, toEnum,
                 (&&), (||), (==), (++), ($), (-) )

import Control.Exception
import Data.ByteString.Lazy
import Data.Int
import Data.Typeable ( Typeable )
import qualified Data.Map as Map
import qualified Data.Set as Set

import Thrift


import Thrift.Content_Types
import Thrift.ContentProvider
seqid = newIORef 0
downloadMesh (ip,op) arg_name = do
  send_downloadMesh op arg_name
  recv_downloadMesh ip
send_downloadMesh op arg_name = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("downloadMesh", M_CALL, seqn)
  write_DownloadMesh_args op (DownloadMesh_args{f_DownloadMesh_args_name=Just arg_name})
  writeMessageEnd op
  tFlush (getTransport op)
recv_downloadMesh ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_DownloadMesh_result ip
  readMessageEnd ip
  case f_DownloadMesh_result_success res of
    Just v -> return v
    Nothing -> do
      throw (AppExn AE_MISSING_RESULT "downloadMesh failed: unknown result")
